patches for DPDK stable branches
 help / color / mirror / Atom feed
From: Vladimir Medvedkin <vladimir.medvedkin@intel.com>
To: dev@dpdk.org
Cc: bruce.richardson@intel.com, stable@dpdk.org,
	Michael Theodore Stolarchuk <mike.stolarchuk@arista.com>
Subject: [PATCH v2 1/3] net/ice: fix possible memory leak
Date: Mon, 15 Jul 2024 18:04:39 +0000	[thread overview]
Message-ID: <20240715180441.3682734-1-vladimir.medvedkin@intel.com> (raw)
In-Reply-To: <20240711165907.3169191-1-vladimir.medvedkin@intel.com>

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 <mike.stolarchuk@arista.com>
Signed-off-by: Vladimir Medvedkin <vladimir.medvedkin@intel.com>
---
 drivers/net/ice/ice_hash.c | 19 ++++++++++++-------
 1 file changed, 12 insertions(+), 7 deletions(-)

diff --git a/drivers/net/ice/ice_hash.c b/drivers/net/ice/ice_hash.c
index f923641533..913f54fca4 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,17 +710,20 @@ 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);
+		goto free_mem;
 
 	rte_memcpy(&meta->raw.prof, &prof, sizeof(prof));
 
+free_mem:
 	rte_free(pkt_buf);
 	rte_free(msk_buf);
+
 	return 0;
 }
 
-- 
2.34.1


       reply	other threads:[~2024-07-15 18:05 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20240711165907.3169191-1-vladimir.medvedkin@intel.com>
2024-07-15 18:04 ` Vladimir Medvedkin [this message]
2024-07-15 18:04   ` [PATCH v2 3/3] net/ice: fix return value for raw pattern parsing function Vladimir Medvedkin
2024-07-17 11:06     ` Bruce Richardson
2024-07-17 11:04   ` [PATCH v2 1/3] net/ice: fix possible memory leak Bruce Richardson
2024-07-22  8:28   ` [PATCH v3 " Vladimir Medvedkin
2024-07-22  8:28     ` [PATCH v3 3/3] net/ice: fix return value for raw pattern parsing function Vladimir Medvedkin
2024-07-22 10:41     ` [PATCH v3 1/3] net/ice: fix possible memory leak Bruce Richardson
2024-07-22 11:00       ` Medvedkin, Vladimir
2024-07-22 10:59     ` [PATCH v4 " Vladimir Medvedkin
2024-07-22 10:59       ` [PATCH v4 3/3] net/ice: fix return value for raw pattern parsing function Vladimir Medvedkin
2024-07-22 13:50       ` [PATCH v5 1/3] net/ice: fix possible memory leak Vladimir Medvedkin
2024-07-22 13:50         ` [PATCH v5 3/3] net/ice: fix return value for raw pattern parsing function Vladimir Medvedkin
2024-07-22 15:11           ` Bruce Richardson
2024-07-22 15:09         ` [PATCH v5 1/3] net/ice: fix possible memory leak Bruce Richardson
2024-07-22 15:18           ` Bruce Richardson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240715180441.3682734-1-vladimir.medvedkin@intel.com \
    --to=vladimir.medvedkin@intel.com \
    --cc=bruce.richardson@intel.com \
    --cc=dev@dpdk.org \
    --cc=mike.stolarchuk@arista.com \
    --cc=stable@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).