Skip to contentSkip to conversation

net: fman: memac: Uninitialized variable on error path

PATCH Applied Dan Carpenter 3 participants 4 messages Aug 25, 2022 – Aug 27, 2022

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

PATCH 1/1 net: fman: memac: Uninitialized variable on error path

The "fixed_link" is only allocated sometimes but it's freed unconditionally in the error handling. Set it to NULL so we don't free uninitialized data.

Fixes 9ea4742a55ca ("net: fman: Configure fixed link in memac_initialization")
---
 drivers/net/ethernet/freescale/fman/mac.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/freescale/fman/mac.c +1 -1
index c376b9bf657d..f9a3f85760fb 100644
@@ -389,7 +389,7 @@ static int memac_initialization(struct mac_device *mac_dev,
 {
 	int			 err;
 	struct fman_mac_params	 params;
-	struct fixed_phy_status *fixed_link;
+	struct fixed_phy_status *fixed_link = NULL;
 
 	mac_dev->set_promisc		= memac_set_promiscuous;
 	mac_dev->change_addr		= memac_modify_mac_address;
Signature · 1 line
2.35.1
#1 lore raw
Quoted 16 lines · Dan Carpenter

The "fixed_link" is only allocated sometimes but it's freed unconditionally in the error handling. Set it to NULL so we don't free uninitialized data.

Fixes 9ea4742a55ca ("net: fman: Configure fixed link in memac_initialization")
---
 drivers/net/ethernet/freescale/fman/mac.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/freescale/fman/mac.c +0 -0
index c376b9bf657d..f9a3f85760fb 100644

drivers/net/ethernet/freescale/fman/mac.c static int memac_initialization(struct mac_device *mac_dev, · line 395

Quoted 8 lines
drivers/net/ethernet/freescale/fman/mac.c +1 -1
@@ -389,7 +389,7 @@ static int memac_initialization(struct mac_device *mac_dev,
 {
 	int			 err;
 	struct fman_mac_params	 params;
-	struct fixed_phy_status *fixed_link;
+	struct fixed_phy_status *fixed_link = NULL;
 
 	mac_dev->set_promisc		= memac_set_promiscuous;
 	mac_dev->change_addr		= memac_modify_mac_address;

This is also fixed by [1]

--Sean

[1] https://lore.kernel.org/netdev/[email protected]/

Reviewed-by
#2 lore raw
Quoted 30 lines · Sean Anderson
Quoted 16 lines · Dan Carpenter

The "fixed_link" is only allocated sometimes but it's freed unconditionally in the error handling. Set it to NULL so we don't free uninitialized data.

Fixes 9ea4742a55ca ("net: fman: Configure fixed link in memac_initialization")
---
 drivers/net/ethernet/freescale/fman/mac.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/freescale/fman/mac.c +0 -0
index c376b9bf657d..f9a3f85760fb 100644

drivers/net/ethernet/freescale/fman/mac.c static int memac_initialization(struct mac_device *mac_dev, · line 395

Quoted 8 lines
drivers/net/ethernet/freescale/fman/mac.c +1 -1
@@ -389,7 +389,7 @@ static int memac_initialization(struct mac_device *mac_dev,
 {
 	int			 err;
 	struct fman_mac_params	 params;
-	struct fixed_phy_status *fixed_link;
+	struct fixed_phy_status *fixed_link = NULL;
 
 	mac_dev->set_promisc		= memac_set_promiscuous;
 	mac_dev->change_addr		= memac_modify_mac_address;

This is also fixed by [1]

Quoted 4 lines

--Sean

[1] https://lore.kernel.org/netdev/[email protected]/

Whoops, I didn't read this correctly.

#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 8 lines · On Thu, 25 Aug 2022 16:17:19 +0300 you wrote:

The "fixed_link" is only allocated sometimes but it's freed unconditionally in the error handling. Set it to NULL so we don't free uninitialized data.

Fixes 9ea4742a55ca ("net: fman: Configure fixed link in memac_initialization")

[...]

Here is the summary with links:
- [net-next] net: fman: memac: Uninitialized variable on error path

    https://git.kernel.org/netdev/net-next/c/931d0a8b201a

You are awesome, thank you!

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