Skip to content

Commit 12aece8

Browse files
bluesheep1337davem330
authored andcommitted
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: 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>
1 parent b43f9ac commit 12aece8

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/net/ethernet/sunplus/spl2sw_driver.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,8 +248,8 @@ static int spl2sw_nvmem_get_mac_address(struct device *dev, struct device_node *
248248

249249
/* Check if mac address is valid */
250250
if (!is_valid_ether_addr(mac)) {
251-
kfree(mac);
252251
dev_info(dev, "Invalid mac address in nvmem (%pM)!\n", mac);
252+
kfree(mac);
253253
return -EINVAL;
254254
}
255255

0 commit comments

Comments
 (0)