[PATCH -next] rxrpc: Remove the BUG in rxkad_init_connection_security

Gaosheng Cui cuigaosheng1 at huawei.com
Tue Jul 9 19:00:55 PDT 2024


If crypto_sync_skcipher_setkey fails, we only need to return the
error code, It is not necessary to trigger the BUG directly.

Signed-off-by: Gaosheng Cui <cuigaosheng1 at huawei.com>
---
 net/rxrpc/rxkad.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/net/rxrpc/rxkad.c b/net/rxrpc/rxkad.c
index 104bb1ec9002..75d291ada9e8 100644
--- a/net/rxrpc/rxkad.c
+++ b/net/rxrpc/rxkad.c
@@ -114,9 +114,10 @@ static int rxkad_init_connection_security(struct rxrpc_connection *conn,
 		goto error;
 	}
 
-	if (crypto_sync_skcipher_setkey(ci, token->kad->session_key,
-				   sizeof(token->kad->session_key)) < 0)
-		BUG();
+	ret = crypto_sync_skcipher_setkey(ci, token->kad->session_key,
+					  sizeof(token->kad->session_key));
+	if (ret < 0)
+		goto error_ci;
 
 	switch (conn->security_level) {
 	case RXRPC_SECURITY_PLAIN:
-- 
2.25.1




More information about the linux-afs mailing list