2016-02-24 08:32:13

by Andrzej Hajda

[permalink] [raw]
Subject: [PATCH] 6lowpan: fix error checking code

Bool variable 'fail' is always non-negative, it indicates an error if it
is true.

The problem has been detected using coccinelle script
scripts/coccinelle/tests/unsigned_lesser_than_zero.cocci

Signed-off-by: Andrzej Hajda <[email protected]>
---
net/6lowpan/iphc.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/6lowpan/iphc.c b/net/6lowpan/iphc.c
index d2a565c..0fe954f 100644
--- a/net/6lowpan/iphc.c
+++ b/net/6lowpan/iphc.c
@@ -482,7 +482,7 @@ static int lowpan_uncompress_multicast_ctx_daddr(struct sk_buff *skb,
ipaddr->s6_addr[0] = 0xFF;
fail = lowpan_fetch_skb(skb, &ipaddr->s6_addr[1], 2);
fail |= lowpan_fetch_skb(skb, &ipaddr->s6_addr[12], 4);
- if (fail < 0)
+ if (fail)
return -EIO;

/* take prefix_len and network prefix from the context */
--
1.9.1



2016-02-24 15:16:48

by Marcel Holtmann

[permalink] [raw]
Subject: Re: [PATCH] 6lowpan: fix error checking code

Hi Alex,

> Bool variable 'fail' is always non-negative, it indicates an error if it
> is true.
>
> The problem has been detected using coccinelle script
> scripts/coccinelle/tests/unsigned_lesser_than_zero.cocci
>
> Signed-off-by: Andrzej Hajda <[email protected]>
> ---
> net/6lowpan/iphc.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)

patch has been applied to bluetooth-next tree.

Regards

Marcel


2016-02-24 10:40:38

by Alexander Aring

[permalink] [raw]
Subject: Re: [PATCH] 6lowpan: fix error checking code

Hi,

Am 02/24/2016 um 09:32 AM schrieb Andrzej Hajda:
> Bool variable 'fail' is always non-negative, it indicates an error if it
> is true.
>
> The problem has been detected using coccinelle script
> scripts/coccinelle/tests/unsigned_lesser_than_zero.cocci
>
> Signed-off-by: Andrzej Hajda <[email protected]>

Acked-by: Alexander Aring <[email protected]>

Marcel, can you please apply this patch on bluetooth-next?
Thanks.

- Alex