* [PATCH] ipv6: esp6: use BUG_ON instead of if condition followed by BUG
@ 2017-10-24 16:28 Gustavo A. R. Silva
2017-10-25 4:07 ` Herbert Xu
0 siblings, 1 reply; 6+ messages in thread
From: Gustavo A. R. Silva @ 2017-10-24 16:28 UTC (permalink / raw)
To: Steffen Klassert, Herbert Xu, David S. Miller, Alexey Kuznetsov,
Hideaki YOSHIFUJI
Cc: netdev, linux-kernel, Gustavo A. R. Silva
Use BUG_ON instead of if condition followed by BUG in esp_remove_trailer.
This issue was detected with the help of Coccinelle.
Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com>
---
net/ipv6/esp6.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/net/ipv6/esp6.c b/net/ipv6/esp6.c
index 89910e2..603ff06 100644
--- a/net/ipv6/esp6.c
+++ b/net/ipv6/esp6.c
@@ -483,8 +483,7 @@ static inline int esp_remove_trailer(struct sk_buff *skb)
goto out;
}
- if (skb_copy_bits(skb, skb->len - alen - 2, nexthdr, 2))
- BUG();
+ BUG_ON(skb_copy_bits(skb, skb->len - alen - 2, nexthdr, 2));
ret = -EINVAL;
padlen = nexthdr[0];
--
2.7.4
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] ipv6: esp6: use BUG_ON instead of if condition followed by BUG
2017-10-24 16:28 [PATCH] ipv6: esp6: use BUG_ON instead of if condition followed by BUG Gustavo A. R. Silva
@ 2017-10-25 4:07 ` Herbert Xu
2017-10-26 12:51 ` [PATCH v2] " Gustavo A. R. Silva
0 siblings, 1 reply; 6+ messages in thread
From: Herbert Xu @ 2017-10-25 4:07 UTC (permalink / raw)
To: Gustavo A. R. Silva
Cc: Steffen Klassert, David S. Miller, Alexey Kuznetsov,
Hideaki YOSHIFUJI, netdev, linux-kernel
On Tue, Oct 24, 2017 at 11:28:26AM -0500, Gustavo A. R. Silva wrote:
> Use BUG_ON instead of if condition followed by BUG in esp_remove_trailer.
>
> This issue was detected with the help of Coccinelle.
>
> Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com>
> ---
> net/ipv6/esp6.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/net/ipv6/esp6.c b/net/ipv6/esp6.c
> index 89910e2..603ff06 100644
> --- a/net/ipv6/esp6.c
> +++ b/net/ipv6/esp6.c
> @@ -483,8 +483,7 @@ static inline int esp_remove_trailer(struct sk_buff *skb)
> goto out;
> }
>
> - if (skb_copy_bits(skb, skb->len - alen - 2, nexthdr, 2))
> - BUG();
> + BUG_ON(skb_copy_bits(skb, skb->len - alen - 2, nexthdr, 2));
How about
ret = skb_copy_bits(skb, skb->len - alen - 2, nexthdr, 2);
BUG_ON(ret);
Thanks,
--
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v2] ipv6: esp6: use BUG_ON instead of if condition followed by BUG
2017-10-25 4:07 ` Herbert Xu
@ 2017-10-26 12:51 ` Gustavo A. R. Silva
2017-10-26 22:38 ` Herbert Xu
0 siblings, 1 reply; 6+ messages in thread
From: Gustavo A. R. Silva @ 2017-10-26 12:51 UTC (permalink / raw)
To: Steffen Klassert, Herbert Xu, David S. Miller, Alexey Kuznetsov,
Hideaki YOSHIFUJI
Cc: netdev, linux-kernel, Gustavo A. R. Silva
Use BUG_ON instead of if condition followed by BUG in esp_remove_trailer.
This issue was detected with the help of Coccinelle.
Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com>
---
Changes in v2:
Update the code as suggested by Herbert Xu:
ret = foo();
BUG_ON(ret);
net/ipv6/esp6.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/net/ipv6/esp6.c b/net/ipv6/esp6.c
index 89910e2..da1f6a6 100644
--- a/net/ipv6/esp6.c
+++ b/net/ipv6/esp6.c
@@ -483,8 +483,8 @@ static inline int esp_remove_trailer(struct sk_buff *skb)
goto out;
}
- if (skb_copy_bits(skb, skb->len - alen - 2, nexthdr, 2))
- BUG();
+ ret = skb_copy_bits(skb, skb->len - alen - 2, nexthdr, 2);
+ BUG_ON(ret);
ret = -EINVAL;
padlen = nexthdr[0];
--
2.7.4
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH v2] ipv6: esp6: use BUG_ON instead of if condition followed by BUG
2017-10-26 12:51 ` [PATCH v2] " Gustavo A. R. Silva
@ 2017-10-26 22:38 ` Herbert Xu
2017-10-27 4:12 ` Gustavo A. R. Silva
2017-10-27 10:46 ` Steffen Klassert
0 siblings, 2 replies; 6+ messages in thread
From: Herbert Xu @ 2017-10-26 22:38 UTC (permalink / raw)
To: Gustavo A. R. Silva
Cc: Steffen Klassert, David S. Miller, Alexey Kuznetsov,
Hideaki YOSHIFUJI, netdev, linux-kernel
On Thu, Oct 26, 2017 at 07:51:06AM -0500, Gustavo A. R. Silva wrote:
> Use BUG_ON instead of if condition followed by BUG in esp_remove_trailer.
>
> This issue was detected with the help of Coccinelle.
>
> Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com>
Acked-by: Herbert Xu <herbert@gondor.apana.org.au>
--
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2] ipv6: esp6: use BUG_ON instead of if condition followed by BUG
2017-10-26 22:38 ` Herbert Xu
@ 2017-10-27 4:12 ` Gustavo A. R. Silva
2017-10-27 10:46 ` Steffen Klassert
1 sibling, 0 replies; 6+ messages in thread
From: Gustavo A. R. Silva @ 2017-10-27 4:12 UTC (permalink / raw)
To: Herbert Xu
Cc: Steffen Klassert, David S. Miller, Alexey Kuznetsov,
Hideaki YOSHIFUJI, netdev, linux-kernel
Quoting Herbert Xu <herbert@gondor.apana.org.au>:
> On Thu, Oct 26, 2017 at 07:51:06AM -0500, Gustavo A. R. Silva wrote:
>> Use BUG_ON instead of if condition followed by BUG in esp_remove_trailer.
>>
>> This issue was detected with the help of Coccinelle.
>>
>> Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com>
>
> Acked-by: Herbert Xu <herbert@gondor.apana.org.au>
Thanks!
--
Gustavo A. R. Silva
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2] ipv6: esp6: use BUG_ON instead of if condition followed by BUG
2017-10-26 22:38 ` Herbert Xu
2017-10-27 4:12 ` Gustavo A. R. Silva
@ 2017-10-27 10:46 ` Steffen Klassert
1 sibling, 0 replies; 6+ messages in thread
From: Steffen Klassert @ 2017-10-27 10:46 UTC (permalink / raw)
To: Herbert Xu
Cc: Gustavo A. R. Silva, David S. Miller, Alexey Kuznetsov,
Hideaki YOSHIFUJI, netdev, linux-kernel
On Fri, Oct 27, 2017 at 06:38:36AM +0800, Herbert Xu wrote:
> On Thu, Oct 26, 2017 at 07:51:06AM -0500, Gustavo A. R. Silva wrote:
> > Use BUG_ON instead of if condition followed by BUG in esp_remove_trailer.
> >
> > This issue was detected with the help of Coccinelle.
> >
> > Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com>
>
> Acked-by: Herbert Xu <herbert@gondor.apana.org.au>
Applied to ipsec-next, thanks everyone!
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2017-10-27 10:46 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-10-24 16:28 [PATCH] ipv6: esp6: use BUG_ON instead of if condition followed by BUG Gustavo A. R. Silva
2017-10-25 4:07 ` Herbert Xu
2017-10-26 12:51 ` [PATCH v2] " Gustavo A. R. Silva
2017-10-26 22:38 ` Herbert Xu
2017-10-27 4:12 ` Gustavo A. R. Silva
2017-10-27 10:46 ` Steffen Klassert
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.