patches for DPDK stable branches
 help / color / mirror / Atom feed
From: Xueming Li <xuemingl@nvidia.com>
To: Viacheslav Ovsiienko <viacheslavo@nvidia.com>,
	Thomas Monjalon <thomas@monjalon.net>,
	Ferruh Yigit <ferruh.yigit@intel.com>,
	Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>,
	Olivier Matz <olivier.matz@6wind.com>,
	Matan Azrad <matan@nvidia.com>
Cc: dev@dpdk.org, xuemingl@nvidia.com, Asaf Penso <asafp@nvidia.com>,
	gaetan.rivet@6wind.com, stable@dpdk.org
Subject: [dpdk-stable] [RFC 3/9] devargs: fix memory leak in legacy parser
Date: Fri, 18 Dec 2020 15:16:48 +0000	[thread overview]
Message-ID: <1608304614-13908-4-git-send-email-xuemingl@nvidia.com> (raw)
In-Reply-To: <1608304614-13908-1-git-send-email-xuemingl@nvidia.com>

Data field was designed as parser buffer, will be released once in
releasing struct memory. The duplicated device arguments was not saved
to data and this caused memory leak.

This patch fixes this leak by saving to new allocated memory to data
field.

Fixes: 4969f5914c9e ("devargs: introduce new parsing helper")
Cc: gaetan.rivet@6wind.com
Cc: stable@dpdk.org

Signed-off-by: Xueming Li <xuemingl@nvidia.com>
---
 lib/librte_eal/common/eal_common_devargs.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/lib/librte_eal/common/eal_common_devargs.c b/lib/librte_eal/common/eal_common_devargs.c
index f36f71fbce..3c4774c88a 100644
--- a/lib/librte_eal/common/eal_common_devargs.c
+++ b/lib/librte_eal/common/eal_common_devargs.c
@@ -224,13 +224,14 @@ rte_devargs_parse(struct rte_devargs *da, const char *dev)
 	da->bus = bus;
 	/* Parse eventual device arguments */
 	if (devname[i] == ',')
-		da->args = strdup(&devname[i + 1]);
+		da->data = strdup(&devname[i + 1]);
 	else
-		da->args = strdup("");
-	if (da->args == NULL) {
+		da->data = strdup("");
+	if (da->data == NULL) {
 		RTE_LOG(ERR, EAL, "not enough memory to parse arguments\n");
 		return -ENOMEM;
 	}
+	da->args = da->data;
 	return 0;
 }
 
-- 
2.25.1


  parent reply	other threads:[~2020-12-18 15:17 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1608304614-13908-1-git-send-email-xuemingl@nvidia.com>
2020-12-18 15:16 ` [dpdk-stable] [RFC 1/9] devargs: fix data buffer storage type Xueming Li
2021-01-08 14:54   ` [dpdk-stable] [PATCH v1 1/7] " Xueming Li
2021-01-08 14:54   ` [dpdk-stable] [PATCH v1 2/7] devargs: fix memory leak on parsing error Xueming Li
2021-01-08 14:54   ` [dpdk-stable] [PATCH v1 3/7] devargs: fix memory leak in legacy parser Xueming Li
2021-01-08 14:54   ` [dpdk-stable] [PATCH v1 4/7] devargs: fix buffer data memory leak Xueming Li
2021-01-18 15:16   ` [dpdk-stable] [PATCH v2 1/5] devargs: fix memory leak on parsing error Xueming Li
2021-03-18  9:12     ` [dpdk-stable] [dpdk-dev] " Thomas Monjalon
2021-03-30 12:15   ` [dpdk-stable] [PATCH v3 2/5] " Xueming Li
2021-04-10 14:23   ` [dpdk-stable] [PATCH v4 " Xueming Li
2021-04-13  3:14   ` [dpdk-stable] [PATCH v5 " Xueming Li
2020-12-18 15:16 ` [dpdk-stable] [RFC 2/9] " Xueming Li
2020-12-18 15:16 ` Xueming Li [this message]
2020-12-18 15:16 ` [dpdk-stable] [RFC 4/9] devargs: fix buffer data memory leak Xueming Li

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=1608304614-13908-4-git-send-email-xuemingl@nvidia.com \
    --to=xuemingl@nvidia.com \
    --cc=andrew.rybchenko@oktetlabs.ru \
    --cc=asafp@nvidia.com \
    --cc=dev@dpdk.org \
    --cc=ferruh.yigit@intel.com \
    --cc=gaetan.rivet@6wind.com \
    --cc=matan@nvidia.com \
    --cc=olivier.matz@6wind.com \
    --cc=stable@dpdk.org \
    --cc=thomas@monjalon.net \
    --cc=viacheslavo@nvidia.com \
    /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).