Skip to content

Commit d6fef10

Browse files
Md Fahad Iqbal PolashJeff Kirsher
authored andcommitted
ice: Fix insufficient memory issue in ice_aq_manage_mac_read
For the MAC read operation, the device can return up to two (LAN and WoL) MAC addresses. Without access to adequate memory, the device will return an error. Fixed this by allocating the right amount of memory. Also, logic to detect and copy the LAN MAC address into the port_info structure has been added. Note that the WoL MAC address is ignored currently as the WoL feature isn't supported yet. Fixes: dc49c77 ("ice: Get MAC/PHY/link info and scheduler topology") Signed-off-by: Md Fahad Iqbal Polash <[email protected]> Signed-off-by: Anirudh Venkataramanan <[email protected]> Tested-by: Tony Brelinski <[email protected]> Signed-off-by: Jeff Kirsher <[email protected]>
1 parent 30d8439 commit d6fef10

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

drivers/net/ethernet/intel/ice/ice_common.c

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ ice_aq_manage_mac_read(struct ice_hw *hw, void *buf, u16 buf_size,
7878
struct ice_aq_desc desc;
7979
enum ice_status status;
8080
u16 flags;
81+
u8 i;
8182

8283
cmd = &desc.params.mac_read;
8384

@@ -98,8 +99,16 @@ ice_aq_manage_mac_read(struct ice_hw *hw, void *buf, u16 buf_size,
9899
return ICE_ERR_CFG;
99100
}
100101

101-
ether_addr_copy(hw->port_info->mac.lan_addr, resp->mac_addr);
102-
ether_addr_copy(hw->port_info->mac.perm_addr, resp->mac_addr);
102+
/* A single port can report up to two (LAN and WoL) addresses */
103+
for (i = 0; i < cmd->num_addr; i++)
104+
if (resp[i].addr_type == ICE_AQC_MAN_MAC_ADDR_TYPE_LAN) {
105+
ether_addr_copy(hw->port_info->mac.lan_addr,
106+
resp[i].mac_addr);
107+
ether_addr_copy(hw->port_info->mac.perm_addr,
108+
resp[i].mac_addr);
109+
break;
110+
}
111+
103112
return 0;
104113
}
105114

@@ -464,9 +473,12 @@ enum ice_status ice_init_hw(struct ice_hw *hw)
464473
if (status)
465474
goto err_unroll_sched;
466475

467-
/* Get port MAC information */
468-
mac_buf_len = sizeof(struct ice_aqc_manage_mac_read_resp);
469-
mac_buf = devm_kzalloc(ice_hw_to_dev(hw), mac_buf_len, GFP_KERNEL);
476+
/* Get MAC information */
477+
/* A single port can report up to two (LAN and WoL) addresses */
478+
mac_buf = devm_kcalloc(ice_hw_to_dev(hw), 2,
479+
sizeof(struct ice_aqc_manage_mac_read_resp),
480+
GFP_KERNEL);
481+
mac_buf_len = 2 * sizeof(struct ice_aqc_manage_mac_read_resp);
470482

471483
if (!mac_buf) {
472484
status = ICE_ERR_NO_MEMORY;

0 commit comments

Comments
 (0)