Skip to contentSkip to conversation

net/ice: fix PHY capabilities buffer leak

PATCH Applied Anurag Mandal 3 participants 3 messages Sep 30 – Oct 6 Network drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net/ice: fix PHY capabilities buffer leak

ice_phy_conf_link() allocates the PHY capabilities buffer and only then validates hw->port_info.
If hw->port_info is NULL,it returns directly without freeing PHY capabilities buffer causing the buffer leak.

This patch fixes the issue by moving the hw->port_info NULL check above the PHY capabilities buffer allocation.

Fixes 36afbc269081 ("net/ice: support link speed change")
---
 drivers/net/intel/ice/ice_ethdev.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/net/intel/ice/ice_ethdev.c +3 -3
index 2c5ffe07f3..dd23a7555c 100644
@@ -5253,14 +5253,14 @@ ice_phy_conf_link(struct ice_hw *hw,
 	u64 phy_type_low = 0;
 	u64 phy_type_high = 0;
 
+	if (!pi)
+		return -EIO;
+
 	phy_caps = (struct ice_aqc_get_phy_caps_data *)
 		ice_malloc(hw, sizeof(*phy_caps));
 	if (!phy_caps)
 		return ICE_ERR_NO_MEMORY;
 
-	if (!pi)
-		return -EIO;
-
 
 	if (ice_fw_supports_report_dflt_cfg(pi->hw))
 		err = ice_aq_get_phy_caps(pi, false, ICE_AQC_REPORT_DFLT_CFG,
Signature · 1 line
2.34.1
Acked-by on v1 1/1
#1 lore raw
Quoted 5 lines · Anurag Mandal

ice_phy_conf_link() allocates the PHY capabilities buffer and only then validates hw->port_info.
If hw->port_info is NULL,it returns directly without freeing PHY capabilities buffer causing the buffer leak.

Quoted 8 lines

This patch fixes the issue by moving the hw->port_info NULL check above the PHY capabilities buffer allocation.

Fixes 36afbc269081 ("net/ice: support link speed change")

---

Signature · 2 lines
Thanks,
Anatoly
#2 lore raw
Quoted 9 lines · Anatoly
Quoted 8 lines · Anurag Mandal

ice_phy_conf_link() allocates the PHY capabilities buffer and only then validates hw->port_info.
If hw->port_info is NULL,it returns directly without freeing PHY capabilities buffer causing the buffer leak.

This patch fixes the issue by moving the hw->port_info NULL check above the PHY capabilities buffer allocation.

Quoted 8 lines
Quoted 5 lines
Fixes 36afbc269081 ("net/ice: support link speed change")

---

Applied to dpdk-next-net-intel.

Thanks,
/Bruce