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 CABBB454EF; Tue, 25 Jun 2024 13:19:02 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D184542DDC; Tue, 25 Jun 2024 13:16:30 +0200 (CEST) Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.19]) by mails.dpdk.org (Postfix) with ESMTP id F215442DC3 for ; Tue, 25 Jun 2024 13:15:47 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1719314148; x=1750850148; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=rk0nxMLCvSMx0D/FiOH31107nolVoMb3rtV+WXYfYbw=; b=AA6Ufg9y1pvUDhRN8RLvkBRNAWWVshrbB8zjpVgaOG1l0q5bqEaFeAyq L8Uc+B3GejhxCj5kX6eNagntSboR3FJasTltAvmyTrUwhQOJdwppiNint ly9IwpViQs1XcrTVBp23HittJY/tYGLj2P/fufK8F7+6Hz7KryooVxOtO 2M5LENtmXW59tttZYCk2vJ6dom1YGpsxVrOD5zkCSoooOi2H9vVwULFbE CD4402+/mhmMWOgUSTtC2u6Pmhq54k/BVy5+L7xdg+PcLQcyG4SNZbgCS lBL+dch10dgdqGW25HBFhcvVdt0F4IOS/m5bQ0UTKFt8jy64KT1SVspNJ Q==; X-CSE-ConnectionGUID: WiYfn7ihTGaMat4u+rpdsQ== X-CSE-MsgGUID: l1KGie8uSnGWvoY6EF88qQ== X-IronPort-AV: E=McAfee;i="6700,10204,11113"; a="16080136" X-IronPort-AV: E=Sophos;i="6.08,263,1712646000"; d="scan'208";a="16080136" Received: from orviesa009.jf.intel.com ([10.64.159.149]) by fmvoesa113.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Jun 2024 04:15:47 -0700 X-CSE-ConnectionGUID: h1t6RaP8TlOytDxbNMJtNg== X-CSE-MsgGUID: 0iKiwPUITKq4ZFBLo9loVg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,263,1712646000"; d="scan'208";a="43719066" Received: from unknown (HELO silpixa00401119.ir.intel.com) ([10.55.129.167]) by orviesa009.jf.intel.com with ESMTP; 25 Jun 2024 04:15:47 -0700 From: Anatoly Burakov To: dev@dpdk.org Cc: Fabio Pricoco , bruce.richardson@intel.com, ian.stokes@intel.com Subject: [PATCH v3 029/129] net/ice/base: fix resource leak Date: Tue, 25 Jun 2024 12:12:34 +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