Skip to contentSkip to conversation

rxrpc: Fix wrong error return in rxrpc_connect_call()

PATCH Applied David Howells 3 participants 3 messages Jan 11, 2023 – Jan 13, 2023

Subsystems (3)
lore
Share & tools
lore

David Howells

author maintainer
#0 lore raw

PATCH 1/1 rxrpc: Fix wrong error return in rxrpc_connect_call()

Fix rxrpc_connect_call() to return -ENOMEM rather than 0 if it fails to look up a peer.

This generated a smatch warning:
net/rxrpc/call_object.c:303 rxrpc_connect_call() warn: missing error code 'ret'

I think this also fixes a syzbot-found bug:

        rxrpc: Assertion failed - 1(0x1) == 11(0xb) is false
        ------------[ cut here ]------------
        kernel BUG at net/rxrpc/call_object.c:645!

where the call being put is in the wrong state - as would be the case if we failed to clear up correctly after the error in rxrpc_connect_call().

Fixes 9d35d880e0e4 ("rxrpc: Move client call connection to the I/O thread")
Reported-and-tested-by [email protected]
---
 net/rxrpc/call_object.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/rxrpc/call_object.c +1 -1
index 3ded5a24627c..f3c9f0201c15 100644
@@ -294,7 +294,7 @@ static void rxrpc_put_call_slot(struct rxrpc_call *call)
 static int rxrpc_connect_call(struct rxrpc_call *call, gfp_t gfp)
 {
 	struct rxrpc_local *local = call->local;
-	int ret = 0;
+	int ret = -ENOMEM;
 
 	_enter("{%d,%lx},", call->debug_id, call->user_call_ID);
 
Reviewed-by Alexander Duyck on v1 1/1
#1 lore raw
Quoted 31 lines · David Howells

Fix rxrpc_connect_call() to return -ENOMEM rather than 0 if it fails to look up a peer.

This generated a smatch warning:
net/rxrpc/call_object.c:303 rxrpc_connect_call() warn: missing error code 'ret'

I think this also fixes a syzbot-found bug:

        rxrpc: Assertion failed - 1(0x1) == 11(0xb) is false
        ------------[ cut here ]------------
        kernel BUG at net/rxrpc/call_object.c:645!

where the call being put is in the wrong state - as would be the case if we failed to clear up correctly after the error in rxrpc_connect_call().

Fixes 9d35d880e0e4 ("rxrpc: Move client call connection to the I/O thread")
Reported-and-tested-by [email protected]
---
 net/rxrpc/call_object.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/rxrpc/call_object.c +0 -0
index 3ded5a24627c..f3c9f0201c15 100644

net/rxrpc/call_object.c static void rxrpc_put_call_slot(struct rxrpc_call *call) · line 300

Quoted 8 lines
net/rxrpc/call_object.c +1 -1
@@ -294,7 +294,7 @@ static void rxrpc_put_call_slot(struct rxrpc_call *call)
 static int rxrpc_connect_call(struct rxrpc_call *call, gfp_t gfp)
 {
 	struct rxrpc_local *local = call->local;
-	int ret = 0;
+	int ret = -ENOMEM;
 
 	_enter("{%d,%lx},", call->debug_id, call->user_call_ID);
 

Looks good to me.

maintainer Applied
#2 lore raw
In reply to David Howells
Quoted 6 lines · On Wed, 11 Jan 2023 18:07:15 +0000 David Howells wrote:

Fix rxrpc_connect_call() to return -ENOMEM rather than 0 if it fails to look up a peer.

This generated a smatch warning:
net/rxrpc/call_object.c:303 rxrpc_connect_call() warn: missing error code 'ret'

Quoted 8 lines

I think this also fixes a syzbot-found bug:

        rxrpc: Assertion failed - 1(0x1) == 11(0xb) is false
        ------------[ cut here ]------------
        kernel BUG at net/rxrpc/call_object.c:645!

where the call being put is in the wrong state - as would be the case if we failed to clear up correctly after the error in rxrpc_connect_call().

Applied, thanks!