diff mbox series

[net-next] xfrm: use BUG_ON instead of if condition followed by BUG

Message ID 20210607091121.2766815-1-zhengyongjun3@huawei.com (mailing list archive)
State Rejected
Delegated to: Netdev Maintainers
Headers show
Series [net-next] xfrm: use BUG_ON instead of if condition followed by BUG | expand

Checks

Context Check Description
netdev/cover_letter success Link
netdev/fixes_present success Link
netdev/patch_count success Link
netdev/tree_selection success Clearly marked for net-next
netdev/subject_prefix success Link
netdev/cc_maintainers success CCed 5 of 5 maintainers
netdev/source_inline success Was 0 now: 0
netdev/verify_signedoff success Link
netdev/module_param success Was 0 now: 0
netdev/build_32bit success Errors and warnings before: 11 this patch: 11
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/verify_fixes success Link
netdev/checkpatch warning WARNING: Avoid crashing the kernel - try using WARN_ON & recovery code rather than BUG() or BUG_ON() WARNING: line length of 81 exceeds 80 columns
netdev/build_allmodconfig_warn success Errors and warnings before: 11 this patch: 11
netdev/header_inline success Link

Commit Message

Zheng Yongjun June 7, 2021, 9:11 a.m. UTC
Use BUG_ON instead of if condition followed by BUG.

This issue was detected with the help of Coccinelle.

Signed-off-by: Zheng Yongjun <zhengyongjun3@huawei.com>
---
 net/xfrm/xfrm_policy.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

Comments

Herbert Xu June 7, 2021, 9:04 a.m. UTC | #1
On Mon, Jun 07, 2021 at 05:11:21PM +0800, Zheng Yongjun wrote:
> Use BUG_ON instead of if condition followed by BUG.
> 
> This issue was detected with the help of Coccinelle.
> 
> Signed-off-by: Zheng Yongjun <zhengyongjun3@huawei.com>
> ---
>  net/xfrm/xfrm_policy.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c
> index ce500f847b99..532314578151 100644
> --- a/net/xfrm/xfrm_policy.c
> +++ b/net/xfrm/xfrm_policy.c
> @@ -421,8 +421,7 @@ void xfrm_policy_destroy(struct xfrm_policy *policy)
>  {
>  	BUG_ON(!policy->walk.dead);
>  
> -	if (del_timer(&policy->timer) || del_timer(&policy->polq.hold_timer))
> -		BUG();
> +	BUG_ON(del_timer(&policy->timer) || del_timer(&policy->polq.hold_timer));

Nack.  Do not put statements with side effects within BUG_ON.
diff mbox series

Patch

diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c
index ce500f847b99..532314578151 100644
--- a/net/xfrm/xfrm_policy.c
+++ b/net/xfrm/xfrm_policy.c
@@ -421,8 +421,7 @@  void xfrm_policy_destroy(struct xfrm_policy *policy)
 {
 	BUG_ON(!policy->walk.dead);
 
-	if (del_timer(&policy->timer) || del_timer(&policy->polq.hold_timer))
-		BUG();
+	BUG_ON(del_timer(&policy->timer) || del_timer(&policy->polq.hold_timer));
 
 	call_rcu(&policy->rcu, xfrm_policy_destroy_rcu);
 }