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 31E90454EF; Tue, 25 Jun 2024 13:22:24 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 9734E42F53; Tue, 25 Jun 2024 13:18:03 +0200 (CEST) Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.19]) by mails.dpdk.org (Postfix) with ESMTP id A2B7442D7D for ; Tue, 25 Jun 2024 13:16:53 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1719314214; x=1750850214; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=YFPwnrPTLBe7PNO00Pqm/NB3E1fiKdYun9GDymNJwxo=; b=bWeZ4ZyE70loJGbJD7HNwg1GHPRHR9/TQf4H/J9zLmNZHHtf63NDq9zo Nd8cbcixsECiq44Ot2zaKBiWCBCeGnCYDqN18OyK/8cDKI+69t9ASxnJ5 So2s/aaPm4JF8wVNshWID0fzFI++UJsKPhTwZVVU0VqhDrQ4lYGKuBjfq Ggcwymf4mee0yqUD3Pd9/IdO8a/BuAHcohel7vb5meJGRWqQetYUqAaHp iCWihR0j1VQc/JDpxtnWenZb4sCaGnBjGNb65Z8lXQd0UXZu/C3rkk4Eb 9TPs2jMA8ul1/IKWuxaMqAzZl2a048TBSKxHGTwJg8IAdlNbpQZTyVmjX A==; X-CSE-ConnectionGUID: GNS5OfQ8RCSzAcraMfgcew== X-CSE-MsgGUID: Vw9Lz1LZTb+2sTHB722xig== X-IronPort-AV: E=McAfee;i="6700,10204,11113"; a="16080271" X-IronPort-AV: E=Sophos;i="6.08,263,1712646000"; d="scan'208";a="16080271" 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:16:34 -0700 X-CSE-ConnectionGUID: EVUoiGV4TGeRkANuti6now== X-CSE-MsgGUID: TKmbHyVWQaCY9kSOlje2gw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,263,1712646000"; d="scan'208";a="43719254" Received: from unknown (HELO silpixa00401119.ir.intel.com) ([10.55.129.167]) by orviesa009.jf.intel.com with ESMTP; 25 Jun 2024 04:16:34 -0700 From: Anatoly Burakov To: dev@dpdk.org Cc: NorbertX Ciosek , bruce.richardson@intel.com, ian.stokes@intel.com Subject: [PATCH v3 058/129] net/ice/base: check if recipe buffer was already allocated Date: Tue, 25 Jun 2024 12:13:03 +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: NorbertX Ciosek Check if recipe buffer was already allocated before allocating new one. Without such check it is possible to get memory leak when overwriting pointer address. Signed-off-by: NorbertX Ciosek Signed-off-by: Ian Stokes --- drivers/net/ice/base/ice_switch.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/net/ice/base/ice_switch.c b/drivers/net/ice/base/ice_switch.c index 57bdad5e56..cca18db413 100644 --- a/drivers/net/ice/base/ice_switch.c +++ b/drivers/net/ice/base/ice_switch.c @@ -2573,6 +2573,9 @@ ice_get_recp_frm_fw(struct ice_hw *hw, struct ice_sw_recipe *recps, u8 rid, recps[rid].big_recp = (num_recps > 1); recps[rid].n_grp_count = (u8)num_recps; recps[rid].tun_type = ice_get_tun_type_for_recipe(rid, vlan); + if (recps[rid].root_buf) + ice_free(hw, recps[rid].root_buf); + recps[rid].root_buf = (struct ice_aqc_recipe_data_elem *) ice_memdup(hw, tmp, recps[rid].n_grp_count * sizeof(*recps[rid].root_buf), ICE_NONDMA_TO_NONDMA); -- 2.43.0