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 5031DA2EEB for ; Tue, 10 Sep 2019 09:33:11 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id E19341EBB6; Tue, 10 Sep 2019 09:33:09 +0200 (CEST) Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by dpdk.org (Postfix) with ESMTP id B917C2C38; Tue, 10 Sep 2019 09:33:08 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 10 Sep 2019 00:33:07 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,487,1559545200"; d="scan'208";a="335836515" Received: from irvmail001.ir.intel.com ([163.33.26.43]) by orsmga004.jf.intel.com with ESMTP; 10 Sep 2019 00:33:05 -0700 Received: from wgcvswdev001.ir.intel.com (wgcvswdev001.ir.intel.com [10.102.246.100]) by irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id x8A7X4Xm006757; Tue, 10 Sep 2019 08:33:04 +0100 Received: from wgcvswdev001.ir.intel.com (localhost [127.0.0.1]) by wgcvswdev001.ir.intel.com with ESMTP id x8A7WRE9020529; Tue, 10 Sep 2019 08:32:27 +0100 Received: (from agalyabx@localhost) by wgcvswdev001.ir.intel.com with œ id x8A7WQn8020523; Tue, 10 Sep 2019 08:32:26 +0100 From: Agalya Babu RadhaKrishnan To: dev@dpdk.org Cc: reshma.pattan@intel.com, hemant.agrawal@nxp.com, sachin.saxena@nxp.com, jananeex.m.parthasarathy@intel.com, Agalya Babu RadhaKrishnan , stable@dpdk.org Date: Tue, 10 Sep 2019 08:30:55 +0100 Message-Id: <1568100655-20010-1-git-send-email-agalyax.babu.radhakrishnan@intel.com> X-Mailer: git-send-email 1.7.0.7 Subject: [dpdk-dev] [PATCH] bus/fslmc: fix for resource leak coverity issue 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" From: Agalya Babu RadhaKrishnan 1 issue caught by 344967 Leaked_storage: Variable sep going out of scope leaks the storage it points to. When 'sep' is not null and sep_exist is 0, 'sep' is freed before going out of scope of the function irrespective of 'addr' exists or not. Coverity Issue: 344967 Fixes: e67a61614d0b ("bus/fslmc: support device iteration") Cc: stable@dpdk.org Signed-off-by: Agalya Babu RadhaKrishnan --- drivers/bus/fslmc/fslmc_bus.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/bus/fslmc/fslmc_bus.c b/drivers/bus/fslmc/fslmc_bus.c index a2f482516..60c34098c 100644 --- a/drivers/bus/fslmc/fslmc_bus.c +++ b/drivers/bus/fslmc/fslmc_bus.c @@ -291,10 +291,13 @@ rte_fslmc_parse(const char *name, void *addr) goto err_out; } - if (addr) + if (addr) { strcpy(addr, sep); + if (!sep_exists && sep) + free(sep); + return 0; + } - return 0; err_out: if (!sep_exists && sep) free(sep); -- 2.14.1