From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id D2683A09FD; Fri, 18 Dec 2020 16:18:09 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 57B36CB34; Fri, 18 Dec 2020 16:17:17 +0100 (CET) Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129]) by dpdk.org (Postfix) with ESMTP id 33A92CADB for ; Fri, 18 Dec 2020 16:17:10 +0100 (CET) Received: from Internal Mail-Server by MTLPINE1 (envelope-from xuemingl@nvidia.com) with SMTP; 18 Dec 2020 17:17:04 +0200 Received: from nvidia.com (pegasus05.mtr.labs.mlnx [10.210.16.100]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id 0BIFH4qa010856; Fri, 18 Dec 2020 17:17:04 +0200 From: Xueming Li To: Viacheslav Ovsiienko , Thomas Monjalon , Ferruh Yigit , Andrew Rybchenko , Olivier Matz , Matan Azrad Cc: dev@dpdk.org, xuemingl@nvidia.com, Asaf Penso , gaetan.rivet@6wind.com, stable@dpdk.org Date: Fri, 18 Dec 2020 15:16:47 +0000 Message-Id: <1608304614-13908-3-git-send-email-xuemingl@nvidia.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1608304614-13908-1-git-send-email-xuemingl@nvidia.com> References: <1608304614-13908-1-git-send-email-xuemingl@nvidia.com> Subject: [dpdk-dev] [RFC 2/9] devargs: fix memory leak on parsing error X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 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" This patch fixes memory leak in parsing error handling. Fixes: 338327d731e6 ("devargs: add function to parse device layers") Cc: gaetan.rivet@6wind.com Cc: stable@dpdk.org Signed-off-by: Xueming Li --- lib/librte_eal/common/eal_common_devargs.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/librte_eal/common/eal_common_devargs.c b/lib/librte_eal/common/eal_common_devargs.c index fcf3d9a3cc..f36f71fbce 100644 --- a/lib/librte_eal/common/eal_common_devargs.c +++ b/lib/librte_eal/common/eal_common_devargs.c @@ -163,6 +163,11 @@ rte_devargs_layers_parse(struct rte_devargs *devargs, if (layers[i].kvlist) rte_kvargs_free(layers[i].kvlist); } + if (ret && devargs->data && devargs->data != devstr) { + /* Free duplicated data. */ + free(devargs->data); + devargs->data = NULL; + } if (ret != 0) rte_errno = -ret; return ret; -- 2.25.1