* [PATCH][next] net: mvpp2: cls: fix less than zero check on a u32 variable
@ 2019-05-05 21:38 Colin King
2019-05-06 7:42 ` Maxime Chevallier
2019-05-07 19:15 ` David Miller
0 siblings, 2 replies; 3+ messages in thread
From: Colin King @ 2019-05-05 21:38 UTC (permalink / raw)
To: David S . Miller, Maxime Chevallier, Antoine Tenart, netdev
Cc: kernel-janitors, linux-kernel
From: Colin Ian King <colin.king@canonical.com>
The signed return from the call to mvpp2_cls_c2_port_flow_index is being
assigned to the u32 variable c2.index and then checked for a negative
error condition which is always going to be false. Fix this by assigning
the return to the int variable index and checking this instead.
Addresses-Coverity: ("Unsigned compared against 0")
Fixes: 90b509b39ac9 ("net: mvpp2: cls: Add Classification offload support")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
drivers/net/ethernet/marvell/mvpp2/mvpp2_cls.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/marvell/mvpp2/mvpp2_cls.c b/drivers/net/ethernet/marvell/mvpp2/mvpp2_cls.c
index 4989fb13244f..c10bc257f571 100644
--- a/drivers/net/ethernet/marvell/mvpp2/mvpp2_cls.c
+++ b/drivers/net/ethernet/marvell/mvpp2/mvpp2_cls.c
@@ -1029,12 +1029,14 @@ static int mvpp2_port_c2_tcam_rule_add(struct mvpp2_port *port,
struct flow_action_entry *act;
struct mvpp2_cls_c2_entry c2;
u8 qh, ql, pmap;
+ int index;
memset(&c2, 0, sizeof(c2));
- c2.index = mvpp2_cls_c2_port_flow_index(port, rule->loc);
- if (c2.index < 0)
+ index = mvpp2_cls_c2_port_flow_index(port, rule->loc);
+ if (index < 0)
return -EINVAL;
+ c2.index = index;
act = &rule->flow->action.entries[0];
--
2.20.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH][next] net: mvpp2: cls: fix less than zero check on a u32 variable
2019-05-05 21:38 [PATCH][next] net: mvpp2: cls: fix less than zero check on a u32 variable Colin King
@ 2019-05-06 7:42 ` Maxime Chevallier
2019-05-07 19:15 ` David Miller
1 sibling, 0 replies; 3+ messages in thread
From: Maxime Chevallier @ 2019-05-06 7:42 UTC (permalink / raw)
To: Colin King
Cc: David S . Miller, Antoine Tenart, netdev, kernel-janitors, linux-kernel
Hi Colin,
On Sun, 5 May 2019 22:38:14 +0100
Colin King <colin.king@canonical.com> wrote:
>From: Colin Ian King <colin.king@canonical.com>
>
>The signed return from the call to mvpp2_cls_c2_port_flow_index is being
>assigned to the u32 variable c2.index and then checked for a negative
>error condition which is always going to be false. Fix this by assigning
>the return to the int variable index and checking this instead.
>
>Addresses-Coverity: ("Unsigned compared against 0")
>Fixes: 90b509b39ac9 ("net: mvpp2: cls: Add Classification offload support")
>Signed-off-by: Colin Ian King <colin.king@canonical.com>
>---
> drivers/net/ethernet/marvell/mvpp2/mvpp2_cls.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
>diff --git a/drivers/net/ethernet/marvell/mvpp2/mvpp2_cls.c b/drivers/net/ethernet/marvell/mvpp2/mvpp2_cls.c
>index 4989fb13244f..c10bc257f571 100644
>--- a/drivers/net/ethernet/marvell/mvpp2/mvpp2_cls.c
>+++ b/drivers/net/ethernet/marvell/mvpp2/mvpp2_cls.c
>@@ -1029,12 +1029,14 @@ static int mvpp2_port_c2_tcam_rule_add(struct mvpp2_port *port,
> struct flow_action_entry *act;
> struct mvpp2_cls_c2_entry c2;
> u8 qh, ql, pmap;
>+ int index;
>
> memset(&c2, 0, sizeof(c2));
>
>- c2.index = mvpp2_cls_c2_port_flow_index(port, rule->loc);
>- if (c2.index < 0)
>+ index = mvpp2_cls_c2_port_flow_index(port, rule->loc);
>+ if (index < 0)
> return -EINVAL;
>+ c2.index = index;
>
> act = &rule->flow->action.entries[0];
>
Thanks for the fix, my bad.
Reviewed-by: Maxime Chevallier <maxime.chevallier@bootlin.com>
Maxime
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH][next] net: mvpp2: cls: fix less than zero check on a u32 variable
2019-05-05 21:38 [PATCH][next] net: mvpp2: cls: fix less than zero check on a u32 variable Colin King
2019-05-06 7:42 ` Maxime Chevallier
@ 2019-05-07 19:15 ` David Miller
1 sibling, 0 replies; 3+ messages in thread
From: David Miller @ 2019-05-07 19:15 UTC (permalink / raw)
To: colin.king
Cc: maxime.chevallier, antoine.tenart, netdev, kernel-janitors, linux-kernel
From: Colin King <colin.king@canonical.com>
Date: Sun, 5 May 2019 22:38:14 +0100
> From: Colin Ian King <colin.king@canonical.com>
>
> The signed return from the call to mvpp2_cls_c2_port_flow_index is being
> assigned to the u32 variable c2.index and then checked for a negative
> error condition which is always going to be false. Fix this by assigning
> the return to the int variable index and checking this instead.
>
> Addresses-Coverity: ("Unsigned compared against 0")
> Fixes: 90b509b39ac9 ("net: mvpp2: cls: Add Classification offload support")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
Applied.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-05-07 19:15 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-05 21:38 [PATCH][next] net: mvpp2: cls: fix less than zero check on a u32 variable Colin King
2019-05-06 7:42 ` Maxime Chevallier
2019-05-07 19:15 ` David Miller
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).