From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (xvm-189-124.dc0.ghst.net [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 7A563A0524; Fri, 8 Jan 2021 15:55:45 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 94633141017; Fri, 8 Jan 2021 15:55:17 +0100 (CET) Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129]) by mails.dpdk.org (Postfix) with ESMTP id 7D63F14100D for ; Fri, 8 Jan 2021 15:55:16 +0100 (CET) Received: from Internal Mail-Server by MTLPINE1 (envelope-from xuemingl@nvidia.com) with SMTP; 8 Jan 2021 16:55:11 +0200 Received: from nvidia.com ([172.27.8.145]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id 108Et0Wx013726; Fri, 8 Jan 2021 16:55:09 +0200 From: Xueming Li To: Thomas Monjalon , Ferruh Yigit , Andrew Rybchenko , Olivier Matz Cc: dev@dpdk.org, Viacheslav Ovsiienko , xuemingl@nvidia.com, Asaf Penso , gaetan.rivet@6wind.com, stable@dpdk.org Date: Fri, 8 Jan 2021 22:54:37 +0800 Message-Id: <20210108145441.23320-4-xuemingl@nvidia.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <1608304614-13908-2-git-send-email-xuemingl@nvidia.com> References: <1608304614-13908-2-git-send-email-xuemingl@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v1 3/7] devargs: fix memory leak in legacy parser 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 Sender: "dev" 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 --- 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