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 8DB2D45500; Wed, 26 Jun 2024 13:55:52 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5754F43270; Wed, 26 Jun 2024 13:55:06 +0200 (CEST) Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.9]) by mails.dpdk.org (Postfix) with ESMTP id 742BE42E95 for ; Wed, 26 Jun 2024 13:43:15 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1719402195; x=1750938195; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=rk0nxMLCvSMx0D/FiOH31107nolVoMb3rtV+WXYfYbw=; b=Wzh9i8IK/ppnt6Co3nX3sjcfgfgOwFcTo3ZDAdWj9NATiQrT+97gsu75 3y+b67Wa79BFDbhRDkQbkq6g8G04ZPchxBIxACYVTMY2wokhSjB9Q2CRG 1puXU41P+zfLlj23pnpJsc1Iu3Y6z1euEiXUZfkbcX4dzzJvPACNAY5ai +yuT4wEcFnNoUSfStQg0Qr/llxaStEDlW+we/N3iWZZiOsR0ZNyFL/Em1 IgLJ0jn59uHv6Q2hCJ1lYCvnMq70pkQSU2qqbeu61PzPZgQyRH8wtqeXk QA29Bwy2OI23TF0o/nVb7t8J2hgoKhtWrM/siQpkneIGhf0Hju48HFnxJ Q==; X-CSE-ConnectionGUID: GW5DznSIQ/22ZM6gO1eEpQ== X-CSE-MsgGUID: +6hMe/3fSKWIBWk+IbIjeA== X-IronPort-AV: E=McAfee;i="6700,10204,11114"; a="38979295" X-IronPort-AV: E=Sophos;i="6.08,266,1712646000"; d="scan'208";a="38979295" Received: from orviesa010.jf.intel.com ([10.64.159.150]) by orvoesa101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Jun 2024 04:43:15 -0700 X-CSE-ConnectionGUID: IfUNvonlSu6m8mdBkey07w== X-CSE-MsgGUID: ZzptTeFmQjaS+xxjBKxPhQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,266,1712646000"; d="scan'208";a="43873462" Received: from unknown (HELO silpixa00401119.ir.intel.com) ([10.55.129.167]) by orviesa010.jf.intel.com with ESMTP; 26 Jun 2024 04:43:14 -0700 From: Anatoly Burakov To: dev@dpdk.org Cc: Fabio Pricoco , ian.stokes@intel.com, bruce.richardson@intel.com Subject: [PATCH v4 009/103] net/ice/base: fix resource leak Date: Wed, 26 Jun 2024 12:40:57 +0100 Message-ID: X-Mailer: git-send-email 2.43.0 In-Reply-To: References: 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: Fabio Pricoco 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