[v2,023/148] net/ice/base: fix memory leak when checking firmware version

Message ID 1f8ef2a03bede7e082e9d53860f70a57751982fa.1718204528.git.anatoly.burakov@intel.com (mailing list archive)
State Superseded, archived
Delegated to: Bruce Richardson
Headers
Series Update net/ice base driver to latest upstream snapshot |

Checks

Context Check Description
ci/checkpatch warning coding style issues

Commit Message

Anatoly Burakov June 12, 2024, 3 p.m. UTC
From: Ian Stokes <ian.stokes@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.

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

Patch

diff --git a/drivers/net/ice/base/ice_common.c b/drivers/net/ice/base/ice_common.c
index 4a2421a896..c3d429828d 100644
--- a/drivers/net/ice/base/ice_common.c
+++ b/drivers/net/ice/base/ice_common.c
@@ -3845,8 +3845,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: