Skip to content

Commit

Permalink
SUNRPC: Fix an Oops due to socket not set up yet...
Browse files Browse the repository at this point in the history
We can Oops in both xs_udp_send_request() and xs_tcp_send_request() if the
call to xs_sendpages() returns an error due to the socket not yet being
set up.
Deal with that situation by returning a new error: ENOTSOCK, so that we
know to avoid dereferencing transport->sock.

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
  • Loading branch information
Trond Myklebust authored and Trond Myklebust committed Mar 11, 2009
1 parent d7371c4 commit fba91af
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion net/sunrpc/xprtsock.c
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ static int xs_sendpages(struct socket *sock, struct sockaddr *addr, int addrlen,
int err, sent = 0;

if (unlikely(!sock))
return -ENOTCONN;
return -ENOTSOCK;

clear_bit(SOCK_ASYNC_NOSPACE, &sock->flags);
if (base != 0) {
Expand Down Expand Up @@ -594,6 +594,10 @@ static int xs_udp_send_request(struct rpc_task *task)
}

switch (status) {
case -ENOTSOCK:
status = -ENOTCONN;
/* Should we call xs_close() here? */
break;
case -EAGAIN:
xs_nospace(task);
break;
Expand Down Expand Up @@ -693,6 +697,10 @@ static int xs_tcp_send_request(struct rpc_task *task)
}

switch (status) {
case -ENOTSOCK:
status = -ENOTCONN;
/* Should we call xs_close() here? */
break;
case -EAGAIN:
xs_nospace(task);
break;
Expand Down

0 comments on commit fba91af

Please sign in to comment.