Skip to content

Commit

Permalink
SCTP: Check to make sure file is valid before setting timeout
Browse files Browse the repository at this point in the history
In-kernel sockets created with sock_create_kern don't usually
have a file and file descriptor allocated to them.  As a result,
when SCTP tries to check the non-blocking flag, we Oops when
dereferencing a NULL file pointer.

Signed-off-by: Vlad Yasevich <vladislav.yasevich@hp.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Vlad Yasevich authored and David S. Miller committed Jul 6, 2007
1 parent 3663c30 commit f50f95c
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion net/sctp/socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -980,6 +980,7 @@ static int __sctp_connect(struct sock* sk,
union sctp_addr *sa_addr;
void *addr_buf;
unsigned short port;
unsigned int f_flags = 0;

sp = sctp_sk(sk);
ep = sp->ep;
Expand Down Expand Up @@ -1106,7 +1107,14 @@ static int __sctp_connect(struct sock* sk,
af->to_sk_daddr(&to, sk);
sk->sk_err = 0;

timeo = sock_sndtimeo(sk, sk->sk_socket->file->f_flags & O_NONBLOCK);
/* in-kernel sockets don't generally have a file allocated to them
* if all they do is call sock_create_kern().
*/
if (sk->sk_socket->file)
f_flags = sk->sk_socket->file->f_flags;

timeo = sock_sndtimeo(sk, f_flags & O_NONBLOCK);

err = sctp_wait_for_connect(asoc, &timeo);

/* Don't free association on exit. */
Expand Down

0 comments on commit f50f95c

Please sign in to comment.