Skip to content

Commit

Permalink
eth: sp7021: fix use after free bug in spl2sw_nvmem_get_mac_address
Browse files Browse the repository at this point in the history
This frees "mac" and tries to display its address as part of the error
message on the next line.  Swap the order.

Fixes: fd3040b ("net: ethernet: Add driver for Sunplus SP7021")
Signed-off-by: Zheng Wang <zyytlz.wz@163.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Zheng Wang authored and David S. Miller committed Oct 3, 2022
1 parent b43f9ac commit 12aece8
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/net/ethernet/sunplus/spl2sw_driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit 12aece8

Please sign in to comment.