Skip to contentSkip to conversation

net: microchip: sparx5: Fix uninitialized variable in vcap_path_exist()

PATCH Applied Dan Carpenter 3 participants 4 messages Jan 20, 2023 – Jan 24, 2023

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net: microchip: sparx5: Fix uninitialized variable in vcap_path_exist()

The "eport" variable needs to be initialized to NULL for this code to work.

Fixes 814e7693207f ("net: microchip: vcap api: Add a storage state to a VCAP rule")

---
Probably you had CONFIG_INIT_STACK_ALL=y in your .config for this to pass testing.

 drivers/net/ethernet/microchip/vcap/vcap_api.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/ethernet/microchip/vcap/vcap_api.c +2 -1
index 71f787a78295..69c026778b42 100644
@@ -2012,7 +2012,8 @@ static int vcap_get_next_chain(struct vcap_control *vctrl,
 static bool vcap_path_exist(struct vcap_control *vctrl, struct net_device *ndev,
 			    int dst_cid)
 {
-	struct vcap_enabled_port *eport, *elem;
+	struct vcap_enabled_port *eport = NULL;
+	struct vcap_enabled_port *elem;
 	struct vcap_admin *admin;
 	int tmp;
 
Signature · 1 line
2.35.1
maintainer Reviewed-by on v1 1/1
#1 lore raw

Hi Dan,

Thanks for the fix.

I have not seen any CONFIG_INIT_STACK_ALL=y in any of my .configs, though, so I will be updating my test suite to catch this.

Quoted 33 lines · Dan Carpenter

EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe

The "eport" variable needs to be initialized to NULL for this code to work.

Fixes 814e7693207f ("net: microchip: vcap api: Add a storage state to a VCAP

rule")

---
Probably you had CONFIG_INIT_STACK_ALL=y in your .config for this to pass testing.

 drivers/net/ethernet/microchip/vcap/vcap_api.c | 3 ++-

 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/ethernet/microchip/vcap/vcap_api.c +0 -0
index 71f787a78295..69c026778b42 100644
@@ -2012,7 +2012,8 @@ static int vcap_get_next_chain(struct vcap_control
 *vctrl,

 static bool vcap_path_exist(struct vcap_control *vctrl, struct net_device *ndev,
                            int dst_cid)
 {
-       struct vcap_enabled_port *eport, *elem;
+       struct vcap_enabled_port *eport = NULL;
+       struct vcap_enabled_port *elem;
        struct vcap_admin *admin;
        int tmp;

Quoted 3 lines

--
2.35.1

BR
Steen

#2 lore raw
Quoted 6 lines · Steen Hegelund

Hi Dan,

Thanks for the fix.

I have not seen any CONFIG_INIT_STACK_ALL=y in any of my .configs, though, so I will be updating my test suite to catch this.

No, what I'm saying is that for a lot of people all stack variables are initialized to zero by default so sometimes people are like, "I've tested this a thousand times. How has it even been working?"

In your case I guess it was working because the eport was never not found.

regards,
dan carpenter

#3 lore raw
In reply to Dan Carpenter
This patch was applied to netdev/net-next.git (master) by Jakub Kicinski <[email protected]>:

Hello:

This patch was applied to netdev/net-next.git (master) by Jakub Kicinski <[email protected]>:

Quoted 10 lines · On Fri, 20 Jan 2023 16:47:12 +0300 you wrote:

The "eport" variable needs to be initialized to NULL for this code to work.

Fixes 814e7693207f ("net: microchip: vcap api: Add a storage state to a VCAP rule")

---
Probably you had CONFIG_INIT_STACK_ALL=y in your .config for this to pass testing.

[...]

Here is the summary with links:
- [net-next] net: microchip: sparx5: Fix uninitialized variable in vcap_path_exist()

    https://git.kernel.org/netdev/net-next/c/3bee9b573af5

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html