From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 6661D4404F; Wed, 12 Jun 2024 17:10:52 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3732440E39; Wed, 12 Jun 2024 17:04:23 +0200 (CEST) Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.10]) by mails.dpdk.org (Postfix) with ESMTP id A0A0740E2A for ; Wed, 12 Jun 2024 17:04:20 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1718204661; x=1749740661; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=1pbUv/FDiVULaTzWoSTJ88xiK/WJnx7f3wHwz42/ON8=; b=XoyQRhsYoGyx7zCwU5MaD64MEH+iOWfrHXPHGW1O0zt8DrVF+YlPHqJJ YLmbZM7Z4jHWdaSXnG6kR6C7OkDTs0+qo2/OgtJw3CQXE5SI2h4NFD02N 8okGKCBzgvBH2Mx/4qZZgO1Hs3o56VdkSmtrIVkg76NcZ2n2tjFEw99v0 aDvPOfSoXO3gIyg/+HQbTSVkyEJhnYM/FGUp25pKqaBO/XdYEYmNSJIOj +v1STF/udEyWn46JoJyMCEQ0Mazhc7z/bb3CmXuRZz44UFEyDULPNsTTp GqjlNWAeZuQ2z9+aLW4FGoXqhHo0IZT83UxXHZ90RRQnTPcuc2yU34uNO w==; X-CSE-ConnectionGUID: JVt7x9eCQcmhwvtlUWjwvw== X-CSE-MsgGUID: jetYjRzaRUetkM0FfqIYyA== X-IronPort-AV: E=McAfee;i="6700,10204,11101"; a="32459340" X-IronPort-AV: E=Sophos;i="6.08,233,1712646000"; d="scan'208";a="32459340" Received: from orviesa009.jf.intel.com ([10.64.159.149]) by orvoesa102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Jun 2024 08:04:13 -0700 X-CSE-ConnectionGUID: N+i7qI9MRAy7pBbOBd5KFA== X-CSE-MsgGUID: eg7l/57DTmiqHDkhO4ao7g== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,233,1712646000"; d="scan'208";a="39925083" Received: from silpixa00401119.ir.intel.com ([10.55.129.167]) by orviesa009.jf.intel.com with ESMTP; 12 Jun 2024 08:04:12 -0700 From: Anatoly Burakov To: dev@dpdk.org Cc: Ian Stokes , bruce.richardson@intel.com, Fabio Pricoco Subject: [PATCH v2 034/148] net/ice/base: fix resource leak Date: Wed, 12 Jun 2024 16:00:28 +0100 Message-ID: <82d2c14687c0c248633967af2accc81e36c4b7a9.1718204528.git.anatoly.burakov@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: <20240430154014.1026-1-ian.stokes@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org From: Ian Stokes When errors happen during OROM reads, the allocated buffer is not freed. Fix it by adding a goto label to free the buffer in case of error. Signed-off-by: Fabio Pricoco Signed-off-by: Ian Stokes --- drivers/net/ice/base/ice_nvm.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/net/ice/base/ice_nvm.c b/drivers/net/ice/base/ice_nvm.c index 9cebe7a07b..55e624cb31 100644 --- a/drivers/net/ice/base/ice_nvm.c +++ b/drivers/net/ice/base/ice_nvm.c @@ -748,7 +748,7 @@ ice_get_orom_civd_data(struct ice_hw *hw, enum ice_bank_select bank, orom_data, hw->flash.banks.orom_size); if (status) { ice_debug(hw, ICE_DBG_NVM, "Unable to read Option ROM data\n"); - return status; + goto exit_error;; } /* Scan the memory buffer to locate the CIVD data section */ @@ -772,7 +772,8 @@ ice_get_orom_civd_data(struct ice_hw *hw, enum ice_bank_select bank, if (sum) { ice_debug(hw, ICE_DBG_NVM, "Found CIVD data with invalid checksum of %u\n", sum); - goto err_invalid_checksum; + status = ICE_ERR_NVM; + goto exit_error; } *civd = *tmp; @@ -780,11 +781,12 @@ ice_get_orom_civd_data(struct ice_hw *hw, enum ice_bank_select bank, return 0; } + status = ICE_ERR_NVM; ice_debug(hw, ICE_DBG_NVM, "Unable to locate CIVD data within the Option ROM\n"); -err_invalid_checksum: +exit_error: ice_free(hw, orom_data); - return ICE_ERR_NVM; + return status; } /** -- 2.43.0