Skip to content

Commit 37411ca

Browse files
dhowellsdavem330
authored andcommitted
rxrpc: Fix potential NULL-pointer exception
Fix a potential NULL-pointer exception in rxrpc_do_sendmsg(). The call state check that I added should have gone into the else-body of the if-statement where we actually have a call to check. Found by CoverityScan CID#1414316 ("Dereference after null check"). Fixes: 540b1c4 ("rxrpc: Fix deadlock between call creation and sendmsg/recvmsg") Reported-by: Colin Ian King <[email protected]> Signed-off-by: David Howells <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent b3b6157 commit 37411ca

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

net/rxrpc/sendmsg.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -517,20 +517,21 @@ int rxrpc_do_sendmsg(struct rxrpc_sock *rx, struct msghdr *msg, size_t len)
517517
ret = -EBADSLT;
518518
if (cmd != RXRPC_CMD_SEND_DATA)
519519
goto error_release_sock;
520-
ret = -EBUSY;
521-
if (call->state == RXRPC_CALL_UNINITIALISED ||
522-
call->state == RXRPC_CALL_CLIENT_AWAIT_CONN ||
523-
call->state == RXRPC_CALL_SERVER_PREALLOC ||
524-
call->state == RXRPC_CALL_SERVER_SECURING ||
525-
call->state == RXRPC_CALL_SERVER_ACCEPTING)
526-
goto error_release_sock;
527520
call = rxrpc_new_client_call_for_sendmsg(rx, msg, user_call_ID,
528521
exclusive);
529522
/* The socket is now unlocked... */
530523
if (IS_ERR(call))
531524
return PTR_ERR(call);
532525
/* ... and we have the call lock. */
533526
} else {
527+
ret = -EBUSY;
528+
if (call->state == RXRPC_CALL_UNINITIALISED ||
529+
call->state == RXRPC_CALL_CLIENT_AWAIT_CONN ||
530+
call->state == RXRPC_CALL_SERVER_PREALLOC ||
531+
call->state == RXRPC_CALL_SERVER_SECURING ||
532+
call->state == RXRPC_CALL_SERVER_ACCEPTING)
533+
goto error_release_sock;
534+
534535
ret = mutex_lock_interruptible(&call->user_mutex);
535536
release_sock(&rx->sk);
536537
if (ret < 0) {

0 commit comments

Comments
 (0)