netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] eth: sp7021: fix use after free bug in spl2sw_nvmem_get_mac_address
@ 2022-09-30 17:57 Zheng Wang
  2022-10-03 11:50 ` patchwork-bot+netdevbpf
  0 siblings, 1 reply; 7+ messages in thread
From: Zheng Wang @ 2022-09-30 17:57 UTC (permalink / raw)
  To: netdev
  Cc: wellslutw, davem, linux-kernel, hackerzheng666, alex000young,
	security, edumazet, kuba, pabeni, Zheng Wang

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")
Signed-off-by: Zheng Wang <zyytlz.wz@163.com>
---
 drivers/net/ethernet/sunplus/spl2sw_driver.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/sunplus/spl2sw_driver.c b/drivers/net/ethernet/sunplus/spl2sw_driver.c
index 546206640492..61d1d07dc070 100644
--- a/drivers/net/ethernet/sunplus/spl2sw_driver.c
+++ b/drivers/net/ethernet/sunplus/spl2sw_driver.c
@@ -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;
 	}
 
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread
* [PATCH] eth: sp7021: fix use after free bug in spl2sw_nvmem_get_mac_address
@ 2022-09-30  4:03 Zheng Wang
  2022-09-30 15:48 ` Jakub Kicinski
  0 siblings, 1 reply; 7+ messages in thread
From: Zheng Wang @ 2022-09-30  4:03 UTC (permalink / raw)
  To: netdev
  Cc: wellslutw, davem, linux-kernel, hackerzheng666, alex000young,
	security, edumazet, kuba, pabeni, Zheng Wang

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")

Reported-by: Zheng Wang <hackerzheng666@gmail.com>

Signed-off-by: Zheng Wang <zyytlz.wz@163.com>
---
 drivers/net/ethernet/sunplus/spl2sw_driver.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/sunplus/spl2sw_driver.c b/drivers/net/ethernet/sunplus/spl2sw_driver.c
index 546206640492..61d1d07dc070 100644
--- a/drivers/net/ethernet/sunplus/spl2sw_driver.c
+++ b/drivers/net/ethernet/sunplus/spl2sw_driver.c
@@ -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;
 	}
 
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2022-10-03 11:50 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-09-30 17:57 [PATCH] eth: sp7021: fix use after free bug in spl2sw_nvmem_get_mac_address Zheng Wang
2022-10-03 11:50 ` patchwork-bot+netdevbpf
  -- strict thread matches above, loose matches on Subject: below --
2022-09-30  4:03 Zheng Wang
2022-09-30 15:48 ` Jakub Kicinski
2022-09-30 17:23   ` Zheng Hacker
2022-09-30 17:25     ` Jakub Kicinski
2022-09-30 17:55       ` Zheng Hacker

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).