diff mbox series

[-next] rxrpc: Remove the BUG in rxkad_init_connection_security

Message ID 20240710020055.4116034-1-cuigaosheng1@huawei.com (mailing list archive)
State Not Applicable
Delegated to: Netdev Maintainers
Headers show
Series [-next] rxrpc: Remove the BUG in rxkad_init_connection_security | expand

Checks

Context Check Description
netdev/series_format warning Single patches do not need cover letters; Target tree name not specified in the subject
netdev/tree_selection success Guessed tree name to be net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers success CCed 7 of 7 maintainers
netdev/build_clang success Errors and warnings before: 821 this patch: 821
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 821 this patch: 821
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 13 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/build_32bit success Manual override
netdev/contest success net-next-2024-07-11--18-00 (tests: 696)

Commit Message

cuigaosheng July 10, 2024, 2 a.m. UTC
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@huawei.com>
---
 net/rxrpc/rxkad.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
diff mbox series

Patch

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: