From patchwork Mon Apr 27 14:03:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jasvinder Singh X-Patchwork-Id: 69392 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 C8421A00BE; Mon, 27 Apr 2020 16:03:30 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 53FA81C1B9; Mon, 27 Apr 2020 16:03:30 +0200 (CEST) Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by dpdk.org (Postfix) with ESMTP id E71C31C0C4 for ; Mon, 27 Apr 2020 16:03:27 +0200 (CEST) IronPort-SDR: TfDwP3M98FUzLcZlxpeF8x7XSTR10wYi2jHsoskobinUdkZcr+pil5lnmSGZarj5AVZPRSWI+R Q5uZ59yfBJMA== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Apr 2020 07:03:26 -0700 IronPort-SDR: SsWPt9II08Cknn2wrVp8LtUlD85Jj0Zcek0Ez31o4K6X1ufcBmLpvqw+EJoyio4fbkzPtZJVg2 Z2qAkNkpLvhQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,324,1583222400"; d="scan'208";a="458384982" Received: from silpixa00400517.ir.intel.com ([10.237.214.174]) by fmsmga005.fm.intel.com with ESMTP; 27 Apr 2020 07:03:25 -0700 From: Jasvinder Singh To: dev@dpdk.org Cc: cristian.dumitrescu@intel.com Date: Mon, 27 Apr 2020 15:03:25 +0100 Message-Id: <20200427140325.83191-1-jasvinder.singh@intel.com> X-Mailer: git-send-email 2.21.1 MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH] net/softnic: fix resource 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 pipelines, the caller must free the memory allocated to request message on receiving error response. Coverity Issues: 357676, 357680, 357681, 357682, 357690, 357693, 357711, 357722, 357725, 357734, 357739, 357743, 357747,357762, 357766, 357787 Fixes: 6d4d05402501 ("net/softnic: add command to read stats") Fixes: 202905f3ee4d ("net/softnic: add command to create objects") Fixes: ee19326a4b1e ("net/softnic: add command for pipeline table entries") Fixes: 9bc0ce0ad17c ("net/softnic: add command for meter action") Fixes: 2505030a8383 ("net/softnic: add command for TTL action") Signed-off-by: Jasvinder Singh --- drivers/net/softnic/rte_eth_softnic_thread.c | 65 +++++++++++++++----- 1 file changed, 48 insertions(+), 17 deletions(-) diff --git a/drivers/net/softnic/rte_eth_softnic_thread.c b/drivers/net/softnic/rte_eth_softnic_thread.c index 028911c19..f45dbbe1e 100644 --- a/drivers/net/softnic/rte_eth_softnic_thread.c +++ b/drivers/net/softnic/rte_eth_softnic_thread.c @@ -773,9 +773,9 @@ pipeline_msg_alloc(void) } static void -pipeline_msg_free(struct pipeline_msg_rsp *rsp) +pipeline_msg_free(void *msg) { - free(rsp); + free(msg); } static struct pipeline_msg_rsp * @@ -843,8 +843,10 @@ softnic_pipeline_port_in_stats_read(struct pmd_internals *softnic, /* Send request and wait for response */ rsp = pipeline_msg_send_recv(p, req); - if (rsp == NULL) + if (rsp == NULL) { + pipeline_msg_free(req); return -1; + } /* Read response */ status = rsp->status; @@ -892,8 +894,10 @@ softnic_pipeline_port_in_enable(struct pmd_internals *softnic, /* Send request and wait for response */ rsp = pipeline_msg_send_recv(p, req); - if (rsp == NULL) + if (rsp == NULL) { + pipeline_msg_free(req); return -1; + } /* Read response */ status = rsp->status; @@ -939,8 +943,10 @@ softnic_pipeline_port_in_disable(struct pmd_internals *softnic, /* Send request and wait for response */ rsp = pipeline_msg_send_recv(p, req); - if (rsp == NULL) + if (rsp == NULL) { + pipeline_msg_free(req); return -1; + } /* Read response */ status = rsp->status; @@ -994,8 +1000,10 @@ softnic_pipeline_port_out_stats_read(struct pmd_internals *softnic, /* Send request and wait for response */ rsp = pipeline_msg_send_recv(p, req); - if (rsp == NULL) + if (rsp == NULL) { + pipeline_msg_free(req); return -1; + } /* Read response */ status = rsp->status; @@ -1051,8 +1059,10 @@ softnic_pipeline_table_stats_read(struct pmd_internals *softnic, /* Send request and wait for response */ rsp = pipeline_msg_send_recv(p, req); - if (rsp == NULL) + if (rsp == NULL) { + pipeline_msg_free(req); return -1; + } /* Read response */ status = rsp->status; @@ -1331,8 +1341,10 @@ softnic_pipeline_table_rule_add(struct pmd_internals *softnic, /* Send request and wait for response */ rsp = pipeline_msg_send_recv(p, req); - if (rsp == NULL) + if (rsp == NULL) { + pipeline_msg_free(req); return -1; + } /* Read response */ status = rsp->status; @@ -1415,8 +1427,10 @@ softnic_pipeline_table_rule_add_default(struct pmd_internals *softnic, /* Send request and wait for response */ rsp = pipeline_msg_send_recv(p, req); - if (rsp == NULL) + if (rsp == NULL) { + pipeline_msg_free(req); return -1; + } /* Read response */ status = rsp->status; @@ -1573,8 +1587,10 @@ softnic_pipeline_table_rule_add_bulk(struct pmd_internals *softnic, /* Send request and wait for response */ rsp = pipeline_msg_send_recv(p, req); - if (rsp == NULL) + if (rsp == NULL) { + pipeline_msg_free(req); return -1; + } /* Read response */ status = rsp->status; @@ -1638,8 +1654,10 @@ softnic_pipeline_table_rule_delete(struct pmd_internals *softnic, /* Send request and wait for response */ rsp = pipeline_msg_send_recv(p, req); - if (rsp == NULL) + if (rsp == NULL) { + pipeline_msg_free(req); return -1; + } /* Read response */ status = rsp->status; @@ -1688,8 +1706,10 @@ softnic_pipeline_table_rule_delete_default(struct pmd_internals *softnic, /* Send request and wait for response */ rsp = pipeline_msg_send_recv(p, req); - if (rsp == NULL) + if (rsp == NULL) { + pipeline_msg_free(req); return -1; + } /* Read response */ status = rsp->status; @@ -1748,8 +1768,10 @@ softnic_pipeline_table_rule_stats_read(struct pmd_internals *softnic, /* Send request and wait for response */ rsp = pipeline_msg_send_recv(p, req); - if (rsp == NULL) + if (rsp == NULL) { + pipeline_msg_free(req); return -1; + } /* Read response */ status = rsp->status; @@ -1831,6 +1853,7 @@ softnic_pipeline_table_mtr_profile_add(struct pmd_internals *softnic, rsp = pipeline_msg_send_recv(p, req); if (rsp == NULL) { free(mp); + pipeline_msg_free(req); return -1; } @@ -1888,8 +1911,10 @@ softnic_pipeline_table_mtr_profile_delete(struct pmd_internals *softnic, /* Send request and wait for response */ rsp = pipeline_msg_send_recv(p, req); - if (rsp == NULL) + if (rsp == NULL) { + pipeline_msg_free(req); return -1; + } /* Read response */ status = rsp->status; @@ -1951,8 +1976,10 @@ softnic_pipeline_table_rule_mtr_read(struct pmd_internals *softnic, /* Send request and wait for response */ rsp = pipeline_msg_send_recv(p, req); - if (rsp == NULL) + if (rsp == NULL) { + pipeline_msg_free(req); return -1; + } /* Read response */ status = rsp->status; @@ -2016,8 +2043,10 @@ softnic_pipeline_table_dscp_table_update(struct pmd_internals *softnic, /* Send request and wait for response */ rsp = pipeline_msg_send_recv(p, req); - if (rsp == NULL) + if (rsp == NULL) { + pipeline_msg_free(req); return -1; + } /* Read response */ status = rsp->status; @@ -2081,8 +2110,10 @@ softnic_pipeline_table_rule_ttl_read(struct pmd_internals *softnic, /* Send request and wait for response */ rsp = pipeline_msg_send_recv(p, req); - if (rsp == NULL) + if (rsp == NULL) { + pipeline_msg_free(req); return -1; + } /* Read response */ status = rsp->status;