[PATCH v3 020/129] net/ice/base: fix memory leak when checking firmware version

Anatoly Burakov anatoly.burakov at intel.com
Tue Jun 25 13:12:25 CEST 2024


From: Eric Joyner <eric.joyner at intel.com>

If ice_cfg_phy_fec() goes through case ICE_FEC_DIS_AUTO but the underlying
device firmware isn't the correct version, then the memory used to hold the PHY
capabilities output from the firmware isn't freed.

Fix this by making sure the memory is freed by jumping to the label that frees
the memory instead of returning from the version check immediately.

Fixes: 4b6ede113f55 ("net/ice/base: support auto FEC with FEC disabled")
Cc: qi.z.zhang at intel.com
Cc: stable at dpdk.org

Signed-off-by: Eric Joyner <eric.joyner at intel.com>
Signed-off-by: Ian Stokes <ian.stokes at intel.com>
---
 drivers/net/ice/base/ice_common.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ice/base/ice_common.c b/drivers/net/ice/base/ice_common.c
index 3d787d2a29..ef6696cddf 100644
--- a/drivers/net/ice/base/ice_common.c
+++ b/drivers/net/ice/base/ice_common.c
@@ -3843,8 +3843,10 @@ ice_cfg_phy_fec(struct ice_port_info *pi, struct ice_aqc_set_phy_cfg_data *cfg,
 		break;
 	case ICE_FEC_DIS_AUTO:
 		/* Set No FEC and auto FEC */
-		if (!ice_fw_supports_fec_dis_auto(hw))
-			return ICE_ERR_NOT_SUPPORTED;
+		if (!ice_fw_supports_fec_dis_auto(hw)) {
+			status = ICE_ERR_NOT_SUPPORTED;
+			goto out;
+		}
 		cfg->link_fec_opt |= ICE_AQC_PHY_FEC_DIS;
 		/* fall-through */
 	case ICE_FEC_AUTO:
-- 
2.43.0



More information about the dev mailing list