Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

be2net: Fix NULL pointer dereference in be_cmd_get_mac_from_list

When the parameter pmac_id_valid argument of be_cmd_get_mac_from_list() is
set to false, the driver may request the PMAC_ID from the firmware of the
network card, and this function will store that PMAC_ID at the provided
address pmac_id. This is the contract of this function.

However, there is a location within the driver where both
pmac_id_valid == false and pmac_id == NULL are being passed. This could
result in dereferencing a NULL pointer.

To resolve this issue, it is necessary to pass the address of a stub
variable to the function.

Fixes: 95046b927a54 ("be2net: refactor MAC-addr setup code")
Signed-off-by: Andrey Vatoropin <a.vatoropin@crpt.ru>
Link: https://patch.msgid.link/20260120113734.20193-1-a.vatoropin@crpt.ru
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Andrey Vatoropin and committed by
Jakub Kicinski
82157944 2030c435

+2 -1
+2 -1
drivers/net/ethernet/emulex/benet/be_cmds.c
··· 3801 3801 { 3802 3802 int status; 3803 3803 bool pmac_valid = false; 3804 + u32 pmac_id; 3804 3805 3805 3806 eth_zero_addr(mac); 3806 3807 ··· 3814 3813 adapter->if_handle, 0); 3815 3814 } else { 3816 3815 status = be_cmd_get_mac_from_list(adapter, mac, &pmac_valid, 3817 - NULL, adapter->if_handle, 0); 3816 + &pmac_id, adapter->if_handle, 0); 3818 3817 } 3819 3818 3820 3819 return status;