Skip to contentSkip to conversation

eth: sp7021: fix use after free bug in spl2sw_nvmem_get_mac_address

PATCH Applied Zheng Wang 2 participants 2 messages Sep 30, 2022 – Oct 3, 2022

Subsystems (3)
lore
Share & tools
lore

Zheng Wang

author
#0 lore raw

PATCH 1/1 eth: sp7021: fix use after free bug in spl2sw_nvmem_get_mac_address

This frees "mac" and tries to display its address as part of the error message on the next line. Swap the order.

Fixes fd3040b9394c ("net: ethernet: Add driver for Sunplus SP7021")
---
 drivers/net/ethernet/sunplus/spl2sw_driver.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/sunplus/spl2sw_driver.c +1 -1
index 546206640492..61d1d07dc070 100644
@@ -248,8 +248,8 @@ static int spl2sw_nvmem_get_mac_address(struct device *dev, struct device_node *
 
 	/* Check if mac address is valid */
 	if (!is_valid_ether_addr(mac)) {
-		kfree(mac);
 		dev_info(dev, "Invalid mac address in nvmem (%pM)!\n", mac);
+		kfree(mac);
 		return -EINVAL;
 	}
 
Signature · 1 line
2.25.1
#1 lore raw
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 8 lines · On Sat, 1 Oct 2022 01:57:25 +0800 you wrote:

This frees "mac" and tries to display its address as part of the error message on the next line. Swap the order.

Fixes fd3040b9394c ("net: ethernet: Add driver for Sunplus SP7021")
---
 drivers/net/ethernet/sunplus/spl2sw_driver.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Here is the summary with links:
- eth: sp7021: fix use after free bug in spl2sw_nvmem_get_mac_address

    https://git.kernel.org/netdev/net/c/12aece8b0150

You are awesome, thank you!

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