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

From: Zheng Yongjun
Date: Mon Jun 07 2021 - 04:57:40 EST


Use BUG_ON instead of if condition followed by BUG in ip_frag_next.

This issue was detected with the help of Coccinelle.

Signed-off-by: Zheng Yongjun <zhengyongjun3@xxxxxxxxxx>
---
net/ipv4/ip_output.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/net/ipv4/ip_output.c b/net/ipv4/ip_output.c
index c3efc7d658f6..9d0a7e8beaa8 100644
--- a/net/ipv4/ip_output.c
+++ b/net/ipv4/ip_output.c
@@ -734,8 +734,7 @@ struct sk_buff *ip_frag_next(struct sk_buff *skb, struct ip_frag_state *state)
/*
* Copy a block of the IP datagram.
*/
- if (skb_copy_bits(skb, state->ptr, skb_transport_header(skb2), len))
- BUG();
+ BUG_ON(skb_copy_bits(skb, state->ptr, skb_transport_header(skb2), len));
state->left -= len;

/*
--
2.25.1