Skip to contentSkip to conversation

rxrpc: rxkad: replace if (cond) BUG() with BUG_ON()

PATCH In review Jiapeng Chong 2 participants 2 messages Mar 17, 2021 – Mar 18, 2021

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 rxrpc: rxkad: replace if (cond) BUG() with BUG_ON()

Fix the following coccicheck warnings:

./net/rxrpc/rxkad.c:1140:2-5: WARNING: Use BUG_ON instead of if condition followed by BUG.

---
 net/rxrpc/rxkad.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
net/rxrpc/rxkad.c +2 -3
index e2e9e9b..bfa3d9a 100644
@@ -1135,9 +1135,8 @@ static void rxkad_decrypt_response(struct rxrpc_connection *conn,
 	       ntohl(session_key->n[0]), ntohl(session_key->n[1]));
 
 	mutex_lock(&rxkad_ci_mutex);
-	if (crypto_sync_skcipher_setkey(rxkad_ci, session_key->x,
-					sizeof(*session_key)) < 0)
-		BUG();
+	BUG_ON(crypto_sync_skcipher_setkey(rxkad_ci, session_key->x,
+					sizeof(*session_key)) < 0);
 
 	memcpy(&iv, session_key, sizeof(iv));
 
Signature · 1 line
1.8.3.1
#1 lore raw
Quoted 16 lines · Jiapeng Chong

Fix the following coccicheck warnings:

./net/rxrpc/rxkad.c:1140:2-5: WARNING: Use BUG_ON instead of if condition followed by BUG.

---
 net/rxrpc/rxkad.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
net/rxrpc/rxkad.c +0 -0
index e2e9e9b..bfa3d9a 100644

net/rxrpc/rxkad.c static void rxkad_decrypt_response(struct rxrpc_connection *conn, · line 1139

Quoted 8 lines
net/rxrpc/rxkad.c +2 -3
@@ -1135,9 +1135,8 @@ static void rxkad_decrypt_response(struct rxrpc_connection *conn,
 	       ntohl(session_key->n[0]), ntohl(session_key->n[1]));
 
 	mutex_lock(&rxkad_ci_mutex);
-	if (crypto_sync_skcipher_setkey(rxkad_ci, session_key->x,
-					sizeof(*session_key)) < 0)
-		BUG();
+	BUG_ON(crypto_sync_skcipher_setkey(rxkad_ci, session_key->x,
+					sizeof(*session_key)) < 0);

It will be better to delete this BUG_ON() or find a way to ensure that it doesn't happen and delete after that.

Thanks

Quoted 6 lines
net/rxrpc/rxkad.c +0 -1
 	memcpy(&iv, session_key, sizeof(iv));
 
--

1.8.3.1