ipv4: icmp: use BUG_ON instead of if condition followed by BUG
authorGustavo A. R. Silva <garsilva@embeddedor.com>
Mon, 23 Oct 2017 18:08:14 +0000 (13:08 -0500)
committerDavid S. Miller <davem@davemloft.net>
Tue, 24 Oct 2017 09:44:42 +0000 (18:44 +0900)
Use BUG_ON instead of if condition followed by BUG in icmp_timestamp.

This issue was detected with the help of Coccinelle.

Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/ipv4/icmp.c

index 3c1570d3e22fa8cc283a59b38639f29c4a90420c..1617604c92847d5b0d058fac40dc3707f22348a5 100644 (file)
@@ -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;