From patchwork Mon Jul 22 10:59:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Medvedkin X-Patchwork-Id: 142579 Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 347664567F; Mon, 22 Jul 2024 13:00:14 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 244D6402B9; Mon, 22 Jul 2024 13:00:14 +0200 (CEST) Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.10]) by mails.dpdk.org (Postfix) with ESMTP id 9C6AC4027F; Mon, 22 Jul 2024 12:59:55 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1721645996; x=1753181996; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=D3JjspUW9cMQ299XCFV4uvmhvAaNCZE8MOZTvfVd8UI=; b=XqXbXArJ59WqJZcArTiKtbjd2AuhD16ludgCPj80W5XS0qxK4QOEx4iB A9mvnfPEvQ4kBz0VNJGHdiX2SsAWzY+30evoN4wcelmELKGmE763S/DlP 15cYu6m+u72GBj59oK91MRZU2ecFsoHixOZE0txGhoHjl2ADr5N42qnoX r6Kpa1A1/ZHVbolbl4FRF2z4FRwy53gqT5AzpY+3fSE3XoV8Vlh4pLDg0 uw7oZrJj2JjrpSMaYMsItGQhq+NqhfhjuBzxgseDFPBCKSyWAXbu5Yg+h 1v6TAbwPG0dpc+e4jnUVwRUm8ISBA1gQyvG9wz8GlRPRyoSbJLkyQMe91 A==; X-CSE-ConnectionGUID: SVILNT3JQQaePnTZAcr+ag== X-CSE-MsgGUID: x86/8mUXSaSItQU/gCnEnQ== X-IronPort-AV: E=McAfee;i="6700,10204,11140"; a="36650479" X-IronPort-AV: E=Sophos;i="6.09,227,1716274800"; d="scan'208";a="36650479" Received: from orviesa008.jf.intel.com ([10.64.159.148]) by orvoesa102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Jul 2024 03:59:55 -0700 X-CSE-ConnectionGUID: so9MEUvcQK67LmiFlV41uA== X-CSE-MsgGUID: yq2L57fORoi/POKPgFJ9rw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.09,227,1716274800"; d="scan'208";a="52579715" Received: from unknown (HELO silpixa00401176.ir.intel.com) ([10.243.22.170]) by orviesa008.jf.intel.com with ESMTP; 22 Jul 2024 03:59:54 -0700 From: Vladimir Medvedkin To: dev@dpdk.org Cc: bruce.richardson@intel.com, stable@dpdk.org, Michael Theodore Stolarchuk Subject: [PATCH v4 1/3] net/ice: fix possible memory leak Date: Mon, 22 Jul 2024 10:59:48 +0000 Message-Id: <20240722105950.199804-1-vladimir.medvedkin@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240722082836.176515-1-vladimir.medvedkin@intel.com> References: <20240722082836.176515-1-vladimir.medvedkin@intel.com> MIME-Version: 1.0 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 This patch fixes possible memory leak inside the ice_hash_parse_raw_pattern() due to the lack of a call to rte_free() for previously allocated pkt_buf and msk_buf. Fixes: 1b9c68120a1c ("net/ice: enable protocol agnostic flow offloading in RSS") Cc: stable@dpdk.org Reported-by: Michael Theodore Stolarchuk Signed-off-by: Vladimir Medvedkin --- drivers/net/ice/ice_hash.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/drivers/net/ice/ice_hash.c b/drivers/net/ice/ice_hash.c index f923641533..6b3095e2c5 100644 --- a/drivers/net/ice/ice_hash.c +++ b/drivers/net/ice/ice_hash.c @@ -650,7 +650,7 @@ ice_hash_parse_raw_pattern(struct ice_adapter *ad, uint8_t *pkt_buf, *msk_buf; uint8_t tmp_val = 0; uint8_t tmp_c = 0; - int i, j; + int i, j, ret = 0; if (ad->psr == NULL) return -rte_errno; @@ -670,8 +670,10 @@ ice_hash_parse_raw_pattern(struct ice_adapter *ad, return -ENOMEM; msk_buf = rte_zmalloc(NULL, pkt_len, 0); - if (!msk_buf) + if (!msk_buf) { + rte_free(pkt_buf); return -ENOMEM; + } /* convert string to int array */ for (i = 0, j = 0; i < spec_len; i += 2, j++) { @@ -708,18 +710,22 @@ ice_hash_parse_raw_pattern(struct ice_adapter *ad, msk_buf[j] = tmp_val * 16 + tmp_c - '0'; } - if (ice_parser_run(ad->psr, pkt_buf, pkt_len, &rslt)) - return -rte_errno; + ret = ice_parser_run(ad->psr, pkt_buf, pkt_len, &rslt); + if (ret) + goto free_mem; - if (ice_parser_profile_init(&rslt, pkt_buf, msk_buf, - pkt_len, ICE_BLK_RSS, true, &prof)) - return -rte_errno; + ret = ice_parser_profile_init(&rslt, pkt_buf, msk_buf, + pkt_len, ICE_BLK_RSS, true, &prof); + if (ret) + goto free_mem; rte_memcpy(&meta->raw.prof, &prof, sizeof(prof)); +free_mem: rte_free(pkt_buf); rte_free(msk_buf); - return 0; + + return ret; } static void