diff mbox series

dpaa2-switch: fix default return of dpaa2_switch_flower_parse_mirror_key

Message ID 20220214154139.2891275-1-trix@redhat.com (mailing list archive)
State Accepted
Commit 2a36ed7c1cd55742503bed81d2cc0ea83bd0ad0c
Delegated to: Netdev Maintainers
Headers show
Series dpaa2-switch: fix default return of dpaa2_switch_flower_parse_mirror_key | expand

Checks

Context Check Description
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix warning Target tree name not specified in the subject
netdev/cover_letter success Single patches do not need cover letters
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers success CCed 7 of 7 maintainers
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 18 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/tree_selection success Guessing tree name failed - patch did not apply

Commit Message

Tom Rix Feb. 14, 2022, 3:41 p.m. UTC
From: Tom Rix <trix@redhat.com>

Clang static analysis reports this representative problem
dpaa2-switch-flower.c:616:24: warning: The right operand of '=='
  is a garbage value
  tmp->cfg.vlan_id == vlan) {
                   ^  ~~~~
vlan is set in dpaa2_switch_flower_parse_mirror_key(). However
this function can return success without setting vlan.  So
change the default return to -EOPNOTSUPP.

Fixes: 0f3faece5808 ("dpaa2-switch: add VLAN based mirroring")
Signed-off-by: Tom Rix <trix@redhat.com>
---
 drivers/net/ethernet/freescale/dpaa2/dpaa2-switch-flower.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Ioana Ciornei Feb. 15, 2022, 11:51 a.m. UTC | #1
On Mon, Feb 14, 2022 at 07:41:39AM -0800, trix@redhat.com wrote:
> From: Tom Rix <trix@redhat.com>
> 
> Clang static analysis reports this representative problem
> dpaa2-switch-flower.c:616:24: warning: The right operand of '=='
>   is a garbage value
>   tmp->cfg.vlan_id == vlan) {
>                    ^  ~~~~
> vlan is set in dpaa2_switch_flower_parse_mirror_key(). However
> this function can return success without setting vlan.  So
> change the default return to -EOPNOTSUPP.
> 
> Fixes: 0f3faece5808 ("dpaa2-switch: add VLAN based mirroring")
> Signed-off-by: Tom Rix <trix@redhat.com>


Reviewed-by: Ioana Ciornei <ioana.ciornei@nxp.com>

Thanks!
patchwork-bot+netdevbpf@kernel.org Feb. 15, 2022, 2:40 p.m. UTC | #2
Hello:

This patch was applied to netdev/net.git (master)
by David S. Miller <davem@davemloft.net>:

On Mon, 14 Feb 2022 07:41:39 -0800 you wrote:
> From: Tom Rix <trix@redhat.com>
> 
> Clang static analysis reports this representative problem
> dpaa2-switch-flower.c:616:24: warning: The right operand of '=='
>   is a garbage value
>   tmp->cfg.vlan_id == vlan) {
>                    ^  ~~~~
> vlan is set in dpaa2_switch_flower_parse_mirror_key(). However
> this function can return success without setting vlan.  So
> change the default return to -EOPNOTSUPP.
> 
> [...]

Here is the summary with links:
  - dpaa2-switch: fix default return of dpaa2_switch_flower_parse_mirror_key
    https://git.kernel.org/netdev/net/c/2a36ed7c1cd5

You are awesome, thank you!
diff mbox series

Patch

diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch-flower.c b/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch-flower.c
index d6eefbbf163f..cacd454ac696 100644
--- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch-flower.c
+++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch-flower.c
@@ -532,6 +532,7 @@  static int dpaa2_switch_flower_parse_mirror_key(struct flow_cls_offload *cls,
 	struct flow_rule *rule = flow_cls_offload_flow_rule(cls);
 	struct flow_dissector *dissector = rule->match.dissector;
 	struct netlink_ext_ack *extack = cls->common.extack;
+	int ret = -EOPNOTSUPP;
 
 	if (dissector->used_keys &
 	    ~(BIT(FLOW_DISSECTOR_KEY_BASIC) |
@@ -561,9 +562,10 @@  static int dpaa2_switch_flower_parse_mirror_key(struct flow_cls_offload *cls,
 		}
 
 		*vlan = (u16)match.key->vlan_id;
+		ret = 0;
 	}
 
-	return 0;
+	return ret;
 }
 
 static int