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 24FDF45500; Wed, 26 Jun 2024 13:59:16 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A216843350; Wed, 26 Jun 2024 13:55:45 +0200 (CEST) Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.9]) by mails.dpdk.org (Postfix) with ESMTP id A9E3642E95 for ; Wed, 26 Jun 2024 13:44:04 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1719402244; x=1750938244; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=pLAx1/TLp9iE/MdPlJ20KIDqiC4IHFuCKwFR3ftxt/I=; b=KWKyZhJjuRN+undvHrXra4PdW5Vjg49ZnLeTsALLiKJ72h9cY04IAdGE RvAT558wy00SpcEeFEfEjKsV2Eh6UNl91K5g9+FvnNGmjnPjEtUr61qj9 s7dv8FG6R1IrSdDXLeKwzvfGBI1nyXqKGrK65hTb7HxMeFOsCi7nHAeP1 eXoqscGe/IMcXKi/dFHft7NSEc7ZOVwQiFKbRaNmSODKBMTdH+JPV2MA+ F8j50PQyQnR9eMwqGUeeD+xiLOnytZ2yiYafwrHR3RSoZ5b7PyR6M6XqF DC9UEc+WEfiFxfgg1lbcl1VDoKs+lvAO9kl7RfwUtusRTdAvn1iHYPajK Q==; X-CSE-ConnectionGUID: ITcjJHzERbWW+qWjy3nncQ== X-CSE-MsgGUID: eY8AuFebRjW3EGbOeMA8UQ== X-IronPort-AV: E=McAfee;i="6700,10204,11114"; a="38979396" X-IronPort-AV: E=Sophos;i="6.08,266,1712646000"; d="scan'208";a="38979396" 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:44:04 -0700 X-CSE-ConnectionGUID: ZcfIvIe9T3Kg2etlyoX4NA== X-CSE-MsgGUID: d+YYaW38QCmh2iBI/U3oaQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,266,1712646000"; d="scan'208";a="43873829" Received: from unknown (HELO silpixa00401119.ir.intel.com) ([10.55.129.167]) by orviesa010.jf.intel.com with ESMTP; 26 Jun 2024 04:44:03 -0700 From: Anatoly Burakov To: dev@dpdk.org Cc: NorbertX Ciosek , ian.stokes@intel.com, bruce.richardson@intel.com Subject: [PATCH v4 038/103] net/ice/base: check if recipe buffer was already allocated Date: Wed, 26 Jun 2024 12:41:26 +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 f8d98d8a9e..b48f47c846 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