From patchwork Mon Apr 27 14:05:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jasvinder Singh X-Patchwork-Id: 69393 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 7A3E9A00BE; Mon, 27 Apr 2020 16:05:59 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 0DBAF1C1BE; Mon, 27 Apr 2020 16:05:59 +0200 (CEST) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id 1AF041C1B9 for ; Mon, 27 Apr 2020 16:05:57 +0200 (CEST) IronPort-SDR: D8Ew96r5jScfesCUPyRpeOCTqxSbb0xsNmHcORW3nU66Guzm0gnzcTl6KCtbyhXbl8Czb1b35W XhVnMaLxPkcA== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Apr 2020 07:05:57 -0700 IronPort-SDR: 05AhIEY+MvSncZthlBbATAX23oauTziED/VAjwv6CdfarMdluKBYtZFCMWaTwmJwEZ18CqvaUm Za/dUnJKRlkQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,324,1583222400"; d="scan'208";a="302382806" Received: from silpixa00400517.ir.intel.com ([10.237.214.174]) by FMSMGA003.fm.intel.com with ESMTP; 27 Apr 2020 07:05:56 -0700 From: Jasvinder Singh To: dev@dpdk.org Cc: cristian.dumitrescu@intel.com Date: Mon, 27 Apr 2020 15:05:56 +0100 Message-Id: <20200427140556.83262-1-jasvinder.singh@intel.com> X-Mailer: git-send-email 2.21.1 MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH] net/softnic: fix memory leak 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" When sending request messages to data plane thread, the caller must free the memory allocated to request message on receiving error response. Coverity Issue: 357717, 357772 Fixes: 70709c78fda6 ("net/softnic: add command to enable/disable pipeline") Signed-off-by: Jasvinder Singh --- drivers/net/softnic/rte_eth_softnic_thread.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/drivers/net/softnic/rte_eth_softnic_thread.c b/drivers/net/softnic/rte_eth_softnic_thread.c index d610b1617..028911c19 100644 --- a/drivers/net/softnic/rte_eth_softnic_thread.c +++ b/drivers/net/softnic/rte_eth_softnic_thread.c @@ -255,9 +255,9 @@ thread_msg_alloc(void) } static void -thread_msg_free(struct thread_msg_rsp *rsp) +thread_msg_free(void *msg) { - free(rsp); + free(msg); } static struct thread_msg_rsp * @@ -359,8 +359,10 @@ softnic_thread_pipeline_enable(struct pmd_internals *softnic, /* Send request and wait for response */ rsp = thread_msg_send_recv(softnic, thread_id, req); - if (rsp == NULL) + if (rsp == NULL) { + thread_msg_free(req); return -1; + } /* Read response */ status = rsp->status; @@ -444,8 +446,10 @@ softnic_thread_pipeline_disable(struct pmd_internals *softnic, /* Send request and wait for response */ rsp = thread_msg_send_recv(softnic, thread_id, req); - if (rsp == NULL) + if (rsp == NULL) { + thread_msg_free(req); return -1; + } /* Read response */ status = rsp->status;