Skip to contentSkip to conversation

ipv4: icmp: use BUG_ON instead of if condition followed by BUG

PATCH Applied Gustavo A. R. Silva 2 participants 2 messages Oct 23, 2017 – Oct 24, 2017

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

PATCH 1/1 ipv4: icmp: use BUG_ON instead of if condition followed by BUG

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

This issue was detected with the help of Coccinelle.

---
 net/ipv4/icmp.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
net/ipv4/icmp.c +3 -2
index 3c1570d..1617604 100644
@@ -968,8 +968,9 @@ static bool icmp_timestamp(struct sk_buff *skb)
 	 */
 	icmp_param.data.times[1] = inet_current_timestamp();
 	icmp_param.data.times[2] = icmp_param.data.times[1];
-	if (skb_copy_bits(skb, 0, &icmp_param.data.times[0], 4))
-		BUG();
+
+	BUG_ON(skb_copy_bits(skb, 0, &icmp_param.data.times[0], 4));
+
 	icmp_param.data.icmph	   = *icmp_hdr(skb);
 	icmp_param.data.icmph.type = ICMP_TIMESTAMPREPLY;
 	icmp_param.data.icmph.code = 0;
Signature · 1 line
2.7.4