net/ice: fix PHY capabilities buffer leak
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.
--- drivers/net/intel/ice/ice_ethdev.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/net/intel/ice/ice_ethdev.c +3 -3
@@ -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
Quoted 5 lines · Anurag Mandal
ice_phy_conf_link()allocates the PHY capabilities buffer and only then validateshw->port_info.
Ifhw->port_infois 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_infoNULL check above the PHY capabilities buffer allocation.Fixes 36afbc269081 ("net/ice: support link speed change")Signed-off-by Anurag Mandal <[email protected]>---
Signature · 2 lines
Thanks, Anatoly
Bruce Richardson
AppliedQuoted 9 lines · Anatoly
Quoted 8 lines · Anurag Mandal
ice_phy_conf_link()allocates the PHY capabilities buffer and only then validateshw->port_info.
Ifhw->port_infois NULL,it returns directly without freeing PHY capabilities buffer causing the buffer leak.This patch fixes the issue by moving the
hw->port_infoNULL check above the PHY capabilities buffer allocation.
Quoted 8 lines
Quoted 5 lines
Fixes 36afbc269081 ("net/ice: support link speed change")Signed-off-by Anurag Mandal <[email protected]>---
Acked-by Anatoly Burakov <[email protected]>
Applied to dpdk-next-net-intel.
Thanks,
/Bruce