net: mscc: ocelot: fix using match before it is set
Subsystems (3)
PATCH 1/1 net: mscc: ocelot: fix using match before it is set
From: Tom Rix <[email protected]>
Clang static analysis reports this issue ocelot_flower.c:563:8: warning: 1st function call argument
is an uninitialized value
!is_zero_ether_addr(match.mask->dst)) {
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~The variable match is used before it is set. So move the block.
--- drivers/net/ethernet/mscc/ocelot_flower.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-)
drivers/net/ethernet/mscc/ocelot_flower.c +8 -7
@@ -559,13 +559,6 @@ ocelot_flower_parse_key(struct ocelot *ocelot, int port, bool ingress,return -EOPNOTSUPP ; } -if (filter->block_id ==VCAP_IS1 && - !is_zero_ether_addr (match.mask->dst)) { -NL_SET_ERR_MSG_MOD (extack, -"Key type S1_NORMAL cannot match on destination MAC" ); -return -EOPNOTSUPP ; - } -/* The hw support mac matches only for MAC_ETYPE key, * therefore if other matches(port, tcp flags, etc) are added * then just bail out
@@ -580,6 +573,14 @@ ocelot_flower_parse_key(struct ocelot *ocelot, int port, bool ingress,return -EOPNOTSUPP ;flow_rule_match_eth_addrs (rule, &match); + +if (filter->block_id ==VCAP_IS1 && + !is_zero_ether_addr (match.mask->dst)) { +NL_SET_ERR_MSG_MOD (extack, +"Key type S1_NORMAL cannot match on destination MAC" ); +return -EOPNOTSUPP ; + } + filter->key_type =OCELOT_VCAP_KEY_ETYPE ;ether_addr_copy (filter->key.etype.dmac.value, match.key->dst);
Signature · 1 line
2.26.3
This patch was applied to netdev/net.git (master) by David S. Miller <[email protected]>:
Hello:
This patch was applied to netdev/net.git (master)
by David S. Miller <[email protected]>:
Quoted 9 lines · On Tue, 18 Jan 2022 05:41:10 -0800 you wrote:
From: Tom Rix <[email protected]>
Clang static analysis reports this issue ocelot_flower.c:563:8: warning: 1st function call argument
is an uninitialized value!is_zero_ether_addr(match.mask->dst)) { ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~[...]
Here is the summary with links:
- net: mscc: ocelot: fix using match before it is set
https://git.kernel.org/netdev/net/c/baa59504c1cd
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html
Quoted 8 lines · On Tue, Jan 18, 2022 at 05:41:10AM -0800, [email protected] wrote:
From: Tom Rix <[email protected]>
Clang static analysis reports this issue ocelot_flower.c:563:8: warning: 1st function call argument
is an uninitialized value!is_zero_ether_addr(match.mask->dst)) { ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Quoted 6 lines
The variable match is used before it is set. So move the block.
Fixes 75944fda1dfe ("net: mscc: ocelot: offload ingress skbedit and vlan actions to VCAP IS1")Signed-off-by Tom Rix <[email protected]>---
(sorry for the delay)