* [PATCH] rxrpc: recvmsg: use BUG_ON instead of if condition followed by BUG
@ 2017-10-24 16:20 Gustavo A. R. Silva
2017-10-25 1:41 ` Tom Herbert
0 siblings, 1 reply; 3+ messages in thread
From: Gustavo A. R. Silva @ 2017-10-24 16:20 UTC (permalink / raw)
To: David S. Miller; +Cc: netdev, linux-kernel, Gustavo A. R. Silva
Use BUG_ON instead of if condition followed by BUG.
This issue was detected with the help of Coccinelle.
Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com>
---
net/rxrpc/recvmsg.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/net/rxrpc/recvmsg.c b/net/rxrpc/recvmsg.c
index bdece21..9598b92 100644
--- a/net/rxrpc/recvmsg.c
+++ b/net/rxrpc/recvmsg.c
@@ -243,8 +243,7 @@ static int rxrpc_verify_packet(struct rxrpc_call *call, struct sk_buff *skb,
*/
if ((annotation & RXRPC_RX_ANNO_JUMBO) > 1) {
__be16 tmp;
- if (skb_copy_bits(skb, offset - 2, &tmp, 2) < 0)
- BUG();
+ BUG_ON(skb_copy_bits(skb, offset - 2, &tmp, 2) < 0);
cksum = ntohs(tmp);
seq += (annotation & RXRPC_RX_ANNO_JUMBO) - 1;
}
@@ -503,8 +502,7 @@ int rxrpc_recvmsg(struct socket *sock, struct msghdr *msg, size_t len,
release_sock(&rx->sk);
- if (test_bit(RXRPC_CALL_RELEASED, &call->flags))
- BUG();
+ BUG_ON(test_bit(RXRPC_CALL_RELEASED, &call->flags));
if (test_bit(RXRPC_CALL_HAS_USERID, &call->flags)) {
if (flags & MSG_CMSG_COMPAT) {
--
2.7.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] rxrpc: recvmsg: use BUG_ON instead of if condition followed by BUG
2017-10-24 16:20 [PATCH] rxrpc: recvmsg: use BUG_ON instead of if condition followed by BUG Gustavo A. R. Silva
@ 2017-10-25 1:41 ` Tom Herbert
2017-10-25 2:02 ` Gustavo A. R. Silva
0 siblings, 1 reply; 3+ messages in thread
From: Tom Herbert @ 2017-10-25 1:41 UTC (permalink / raw)
To: Gustavo A. R. Silva
Cc: David S. Miller, Linux Kernel Network Developers, LKML
Please combine these related patches fixing BUG in rxrpc into a patch
set with proper annotation,
Also, can any of these BUG_ONs be replaced by WARN_ONs? Warnings are
generally preferable to crashing the system.
Tom
On Tue, Oct 24, 2017 at 9:20 AM, Gustavo A. R. Silva
<garsilva@embeddedor.com> wrote:
> Use BUG_ON instead of if condition followed by BUG.
>
> This issue was detected with the help of Coccinelle.
>
> Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com>
> ---
> net/rxrpc/recvmsg.c | 6 ++----
> 1 file changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/net/rxrpc/recvmsg.c b/net/rxrpc/recvmsg.c
> index bdece21..9598b92 100644
> --- a/net/rxrpc/recvmsg.c
> +++ b/net/rxrpc/recvmsg.c
> @@ -243,8 +243,7 @@ static int rxrpc_verify_packet(struct rxrpc_call *call, struct sk_buff *skb,
> */
> if ((annotation & RXRPC_RX_ANNO_JUMBO) > 1) {
> __be16 tmp;
> - if (skb_copy_bits(skb, offset - 2, &tmp, 2) < 0)
> - BUG();
> + BUG_ON(skb_copy_bits(skb, offset - 2, &tmp, 2) < 0);
> cksum = ntohs(tmp);
> seq += (annotation & RXRPC_RX_ANNO_JUMBO) - 1;
> }
> @@ -503,8 +502,7 @@ int rxrpc_recvmsg(struct socket *sock, struct msghdr *msg, size_t len,
>
> release_sock(&rx->sk);
>
> - if (test_bit(RXRPC_CALL_RELEASED, &call->flags))
> - BUG();
> + BUG_ON(test_bit(RXRPC_CALL_RELEASED, &call->flags));
>
> if (test_bit(RXRPC_CALL_HAS_USERID, &call->flags)) {
> if (flags & MSG_CMSG_COMPAT) {
> --
> 2.7.4
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] rxrpc: recvmsg: use BUG_ON instead of if condition followed by BUG
2017-10-25 1:41 ` Tom Herbert
@ 2017-10-25 2:02 ` Gustavo A. R. Silva
0 siblings, 0 replies; 3+ messages in thread
From: Gustavo A. R. Silva @ 2017-10-25 2:02 UTC (permalink / raw)
To: Tom Herbert; +Cc: David S. Miller, Linux Kernel Network Developers, LKML
Hi Tom,
Quoting Tom Herbert <tom@herbertland.com>:
> Please combine these related patches fixing BUG in rxrpc into a patch
> set with proper annotation,
>
I can do that.
> Also, can any of these BUG_ONs be replaced by WARN_ONs? Warnings are
> generally preferable to crashing the system.
>
What about WARN_ON_ONCE instead?
Thanks
--
Gustavo A. R. Silva
> Tom
>
>
> On Tue, Oct 24, 2017 at 9:20 AM, Gustavo A. R. Silva
> <garsilva@embeddedor.com> wrote:
>> Use BUG_ON instead of if condition followed by BUG.
>>
>> This issue was detected with the help of Coccinelle.
>>
>> Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com>
>> ---
>> net/rxrpc/recvmsg.c | 6 ++----
>> 1 file changed, 2 insertions(+), 4 deletions(-)
>>
>> diff --git a/net/rxrpc/recvmsg.c b/net/rxrpc/recvmsg.c
>> index bdece21..9598b92 100644
>> --- a/net/rxrpc/recvmsg.c
>> +++ b/net/rxrpc/recvmsg.c
>> @@ -243,8 +243,7 @@ static int rxrpc_verify_packet(struct
>> rxrpc_call *call, struct sk_buff *skb,
>> */
>> if ((annotation & RXRPC_RX_ANNO_JUMBO) > 1) {
>> __be16 tmp;
>> - if (skb_copy_bits(skb, offset - 2, &tmp, 2) < 0)
>> - BUG();
>> + BUG_ON(skb_copy_bits(skb, offset - 2, &tmp, 2) < 0);
>> cksum = ntohs(tmp);
>> seq += (annotation & RXRPC_RX_ANNO_JUMBO) - 1;
>> }
>> @@ -503,8 +502,7 @@ int rxrpc_recvmsg(struct socket *sock, struct
>> msghdr *msg, size_t len,
>>
>> release_sock(&rx->sk);
>>
>> - if (test_bit(RXRPC_CALL_RELEASED, &call->flags))
>> - BUG();
>> + BUG_ON(test_bit(RXRPC_CALL_RELEASED, &call->flags));
>>
>> if (test_bit(RXRPC_CALL_HAS_USERID, &call->flags)) {
>> if (flags & MSG_CMSG_COMPAT) {
>> --
>> 2.7.4
>>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-10-25 2:02 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-10-24 16:20 [PATCH] rxrpc: recvmsg: use BUG_ON instead of if condition followed by BUG Gustavo A. R. Silva
2017-10-25 1:41 ` Tom Herbert
2017-10-25 2:02 ` Gustavo A. R. Silva
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).