From patchwork Mon Oct 26 21:23:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cristian Dumitrescu X-Patchwork-Id: 82237 X-Patchwork-Delegate: david.marchand@redhat.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 5E2F6A04DD; Mon, 26 Oct 2020 22:24:05 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id ADB471E2B; Mon, 26 Oct 2020 22:24:01 +0100 (CET) Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by dpdk.org (Postfix) with ESMTP id 622051D9E for ; Mon, 26 Oct 2020 22:23:59 +0100 (CET) IronPort-SDR: rCHHvopHb2tWGFwR1gE7Kri1+eCE4WWLfr+wr3glVy71YS0Os1oyQUBk0+xohDpMn0fMKfEsug oyaHiW4thavw== X-IronPort-AV: E=McAfee;i="6000,8403,9786"; a="155769346" X-IronPort-AV: E=Sophos;i="5.77,421,1596524400"; d="scan'208";a="155769346" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Oct 2020 14:23:57 -0700 IronPort-SDR: HQi5P/GtsdwpCUS2DvRerWWlnpDbHvE/JeoVxfjpaSXNNXowSQsVJulHyVFp1UmORzQr9ZrGiz XUH611pPv65A== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.77,421,1596524400"; d="scan'208";a="350268707" Received: from silpixa00400573.ir.intel.com (HELO silpixa00400573.ger.corp.intel.com) ([10.237.223.107]) by fmsmga004.fm.intel.com with ESMTP; 26 Oct 2020 14:23:56 -0700 From: Cristian Dumitrescu To: dev@dpdk.org Date: Mon, 26 Oct 2020 21:23:55 +0000 Message-Id: <20201026212355.8769-1-cristian.dumitrescu@intel.com> X-Mailer: git-send-email 2.17.1 Subject: [dpdk-dev] [PATCH] examples/pipeline: 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" Coverity issue: 363041 Fixes: 5074e1d551 ("examples/pipeline: add configuration commands") Signed-off-by: Cristian Dumitrescu --- examples/pipeline/cli.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/examples/pipeline/cli.c b/examples/pipeline/cli.c index 8ac6b3f5f..d0150cfcf 100644 --- a/examples/pipeline/cli.c +++ b/examples/pipeline/cli.c @@ -779,6 +779,18 @@ cmd_pipeline_build(char **tokens, } } +static void +table_entry_free(struct rte_swx_table_entry *entry) +{ + if (!entry) + return; + + free(entry->key); + free(entry->key_mask); + free(entry->action_data); + free(entry); +} + static const char cmd_pipeline_table_update_help[] = "pipeline table update " " "; @@ -885,6 +897,7 @@ cmd_pipeline_table_update(char **tokens, status = rte_swx_ctl_pipeline_table_entry_add(p->ctl, table_name, entry); + table_entry_free(entry); if (status) { snprintf(out, out_size, "Invalid entry in file %s at line %u", @@ -914,6 +927,7 @@ cmd_pipeline_table_update(char **tokens, status = rte_swx_ctl_pipeline_table_entry_delete(p->ctl, table_name, entry); + table_entry_free(entry); if (status) { snprintf(out, out_size, "Invalid entry in file %s at line %u", @@ -942,6 +956,7 @@ cmd_pipeline_table_update(char **tokens, status = rte_swx_ctl_pipeline_table_default_entry_add(p->ctl, table_name, entry); + table_entry_free(entry); if (status) { snprintf(out, out_size, "Invalid entry in file %s at line %u",