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 74F444404F; Wed, 12 Jun 2024 17:16:20 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id DC1D242EBC; Wed, 12 Jun 2024 17:05:32 +0200 (CEST) Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.10]) by mails.dpdk.org (Postfix) with ESMTP id 1386542E65 for ; Wed, 12 Jun 2024 17:05:21 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1718204722; x=1749740722; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=KVfH2vePd5JDoowoCBRS+mL/n/m5DJCL2Gq2qH8c/Vs=; b=D3VHxBNcAC2dxP3yCdt/RLFRtq6hbekGbi3kli4KtqKkQ4adzEyK895+ oiVZRPu7yibTFgjFiRAsp2+YCGMmSu7xVX5tuFqxdjw9A08PtHNx3sVfM CmtANxS6twBKzHFekrWYWEpkhkpCtDTrq40PBJcrxcmKie+foNpS2MZSv d7shNor/mdnvHqyIw6YzsTDWeo/jqzWKY4it0sM/46s9nCT10UCJrmzVH kd7bk0auBJtBUS92ZZtzBd8ppprfGrg/cZ623OO5XTw5vdXTvCCvup2YY wws56U/uZVo9bfUcAPrDE2LDskxs+kDDix88XBRAoGW6Wpag5u9olbF4n g==; X-CSE-ConnectionGUID: AkqQUWuwQZKgefXOicQ7/Q== X-CSE-MsgGUID: jXFCJioXQMyj6QVSvKF3cQ== X-IronPort-AV: E=McAfee;i="6700,10204,11101"; a="32459651" X-IronPort-AV: E=Sophos;i="6.08,233,1712646000"; d="scan'208";a="32459651" 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:05:22 -0700 X-CSE-ConnectionGUID: 3YzEVe4tRTywcYKpzfzeuA== X-CSE-MsgGUID: ZNSW2yajTJCAHEa1eYSnDw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,233,1712646000"; d="scan'208";a="39925516" Received: from silpixa00401119.ir.intel.com ([10.55.129.167]) by orviesa009.jf.intel.com with ESMTP; 12 Jun 2024 08:05:21 -0700 From: Anatoly Burakov To: dev@dpdk.org Cc: Ian Stokes , bruce.richardson@intel.com, NorbertX Ciosek Subject: [PATCH v2 075/148] net/ice/base: check if recipe buffer was already allocated Date: Wed, 12 Jun 2024 16:01:09 +0100 Message-ID: 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 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 62f86aaf13..9d576cabf6 100644 --- a/drivers/net/ice/base/ice_switch.c +++ b/drivers/net/ice/base/ice_switch.c @@ -2577,6 +2577,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