linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] rxrpc: rxkad: replace if (cond) BUG() with BUG_ON()
@ 2021-03-17  3:38 Jiapeng Chong
  2021-03-18  8:14 ` Leon Romanovsky
  0 siblings, 1 reply; 2+ messages in thread
From: Jiapeng Chong @ 2021-03-17  3:38 UTC (permalink / raw)
  To: dhowells; +Cc: davem, kuba, linux-afs, netdev, linux-kernel, 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.

Reported-by: Abaci Robot <abaci@linux.alibaba.com>
Signed-off-by: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>
---
 net/rxrpc/rxkad.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/net/rxrpc/rxkad.c b/net/rxrpc/rxkad.c
index e2e9e9b..bfa3d9a 100644
--- a/net/rxrpc/rxkad.c
+++ b/net/rxrpc/rxkad.c
@@ -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));
 
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] rxrpc: rxkad: replace if (cond) BUG() with BUG_ON()
  2021-03-17  3:38 [PATCH] rxrpc: rxkad: replace if (cond) BUG() with BUG_ON() Jiapeng Chong
@ 2021-03-18  8:14 ` Leon Romanovsky
  0 siblings, 0 replies; 2+ messages in thread
From: Leon Romanovsky @ 2021-03-18  8:14 UTC (permalink / raw)
  To: Jiapeng Chong; +Cc: dhowells, davem, kuba, linux-afs, netdev, linux-kernel

On Wed, Mar 17, 2021 at 11:38:38AM +0800, Jiapeng Chong wrote:
> Fix the following coccicheck warnings:
>
> ./net/rxrpc/rxkad.c:1140:2-5: WARNING: Use BUG_ON instead of if
> condition followed by BUG.
>
> Reported-by: Abaci Robot <abaci@linux.alibaba.com>
> Signed-off-by: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>
> ---
>  net/rxrpc/rxkad.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/net/rxrpc/rxkad.c b/net/rxrpc/rxkad.c
> index e2e9e9b..bfa3d9a 100644
> --- a/net/rxrpc/rxkad.c
> +++ b/net/rxrpc/rxkad.c
> @@ -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

>
>  	memcpy(&iv, session_key, sizeof(iv));
>
> --
> 1.8.3.1
>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-03-18  8:15 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-17  3:38 [PATCH] rxrpc: rxkad: replace if (cond) BUG() with BUG_ON() Jiapeng Chong
2021-03-18  8:14 ` Leon Romanovsky

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).