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 05D67A04DE; Wed, 21 Oct 2020 08:00:46 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 4D9C6AC6D; Wed, 21 Oct 2020 08:00:45 +0200 (CEST) Received: from mail-pg1-f194.google.com (mail-pg1-f194.google.com [209.85.215.194]) by dpdk.org (Postfix) with ESMTP id 3BB91AC63 for ; Wed, 21 Oct 2020 08:00:43 +0200 (CEST) Received: by mail-pg1-f194.google.com with SMTP id t14so853293pgg.1 for ; Tue, 20 Oct 2020 23:00:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=from:to:cc:subject:date:message-id:mime-version; bh=5E40iwnCY+LD2QgLHJDD/ttO35JeqCVTz2rvzV48k6A=; b=TDORwZoloKL/WBcEbqG6voXXgP49Q36fnAojWTkr3MCk5Cv+pbpSOK4/kzEGTd/fjX TEnDLv03OkOcuo0AGVNhovBLDkCHPqLVOMJH7nBS05z/lZANq9quj3GeAOrYxogWixeZ MFAbttVTfV4ezKo9pFWFkjGmRcg6GE7CY6Uj8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version; bh=5E40iwnCY+LD2QgLHJDD/ttO35JeqCVTz2rvzV48k6A=; b=qXcWzMLx7pcm9xBNfTsVsHFeqPeG+mOlThO2E2kgVy/NR+PkciXc9wEfV6FTYwh+ph FxTdnm+UvHkITbua8mBApKKBoS4NZCSwVfjD9ZM1+/W7DwcAXSWIYintbDMSynohX+jO zU322d+NTWNpchYHDGMPKEr4bRsXitYzHSGHP9QQnlIQ4JcgHPz48sdOTMk03+3glcqs wz9l9qBL8X+89rzQJXOQYQXmy5YstENdqWDrtNQvms4ZtzmN6W+/utGKkpjTWHGUJRt8 IxWZY0/mr3ZccuIFvY0R05udqI2YP75kXmrIUQSOgz3JbaUaD+G9Db4d1czdJUcyhBLe f9YQ== X-Gm-Message-State: AOAM532p5xfcE4FHDJzo2pcZk/TGLJ5ALTqRZIuGBa233SJNbE3YElTX vvl/9EGf8fm4s2KBKsCs7pa2roW6p8CYaI8ZvulDC1qFdI/xnHCNR9O7W+x9ZOKFzXmJViouEL7 +wvmeXpO4YHvNczUj5aCaBP01jGXswyjac2Ii2HR+p3pepYkj9WDVO/5L/kPNKH1+3Q== X-Google-Smtp-Source: ABdhPJz4yZNFVcflzVwA3VK68Z+2+L/nUVMfBKT1zY8sqDEzTF9tjbeSStQaNbhTXVrf8WqtgB2z2g== X-Received: by 2002:a63:3e06:: with SMTP id l6mr1827601pga.179.1603260040712; Tue, 20 Oct 2020 23:00:40 -0700 (PDT) Received: from localhost.localdomain ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id 190sm899302pfc.151.2020.10.20.23.00.39 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 20 Oct 2020 23:00:40 -0700 (PDT) From: Ajit Khaparde To: dev@dpdk.org Cc: Kalesh AP Date: Tue, 20 Oct 2020 23:00:32 -0700 Message-Id: <20201021060032.23833-1-ajit.khaparde@broadcom.com> X-Mailer: git-send-email 2.21.1 (Apple Git-122.3) MIME-Version: 1.0 Content-Type: text/plain Content-Transfer-Encoding: 8bit X-Content-Filtered-By: Mailman/MimeDel 2.1.15 Subject: [dpdk-dev] [PATCH] net/bnxt: fix a potential 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" Fix a potential resource leak in case of errors during dev args parsing during device probe. Fixes: 6dc83230b43b ("net/bnxt: support port representor data path") Signed-off-by: Ajit Khaparde Reviewed-by: Kalesh AP --- drivers/net/bnxt/bnxt_ethdev.c | 35 +++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c index 562cf14ba..aa2d9e00e 100644 --- a/drivers/net/bnxt/bnxt_ethdev.c +++ b/drivers/net/bnxt/bnxt_ethdev.c @@ -6285,7 +6285,7 @@ static int bnxt_rep_port_probe(struct rte_pci_device *pci_dev, struct bnxt *backing_bp; uint16_t num_rep; int i, ret = 0; - struct rte_kvargs *kvlist; + struct rte_kvargs *kvlist = NULL; num_rep = eth_da.nb_representor_ports; if (num_rep > BNXT_MAX_VF_REPS) { @@ -6339,49 +6339,79 @@ static int bnxt_rep_port_probe(struct rte_pci_device *pci_dev, * Invoked as for ex: "-w 000:00:0d.0, * rep-based-pf= rep-is-pf=" */ + ret = rte_kvargs_process(kvlist, BNXT_DEVARG_REP_IS_PF, bnxt_parse_devarg_rep_is_pf, (void *)&representor); + if (ret) { + ret = -EINVAL; + goto err; + } /* * Handler for "rep_based_pf" devarg. * Invoked as for ex: "-w 000:00:0d.0, * rep-based-pf= rep-is-pf=" */ + ret = rte_kvargs_process(kvlist, BNXT_DEVARG_REP_BASED_PF, bnxt_parse_devarg_rep_based_pf, (void *)&representor); + if (ret) { + ret = -EINVAL; + goto err; + } /* * Handler for "rep_based_pf" devarg. * Invoked as for ex: "-w 000:00:0d.0, * rep-based-pf= rep-is-pf=" */ + ret = rte_kvargs_process(kvlist, BNXT_DEVARG_REP_Q_R2F, bnxt_parse_devarg_rep_q_r2f, (void *)&representor); + if (ret) { + ret = -EINVAL; + goto err; + } /* * Handler for "rep_based_pf" devarg. * Invoked as for ex: "-w 000:00:0d.0, * rep-based-pf= rep-is-pf=" */ + ret = rte_kvargs_process(kvlist, BNXT_DEVARG_REP_Q_F2R, bnxt_parse_devarg_rep_q_f2r, (void *)&representor); + if (ret) { + ret = -EINVAL; + goto err; + } /* * Handler for "rep_based_pf" devarg. * Invoked as for ex: "-w 000:00:0d.0, * rep-based-pf= rep-is-pf=" */ + ret = rte_kvargs_process(kvlist, BNXT_DEVARG_REP_FC_R2F, bnxt_parse_devarg_rep_fc_r2f, (void *)&representor); + if (ret) { + ret = -EINVAL; + goto err; + } /* * Handler for "rep_based_pf" devarg. * Invoked as for ex: "-w 000:00:0d.0, * rep-based-pf= rep-is-pf=" */ + ret = rte_kvargs_process(kvlist, BNXT_DEVARG_REP_FC_F2R, bnxt_parse_devarg_rep_fc_f2r, (void *)&representor); + if (ret) { + ret = -EINVAL; + goto err; + } } ret = rte_eth_dev_create(&pci_dev->device, name, @@ -6411,6 +6441,7 @@ static int bnxt_rep_port_probe(struct rte_pci_device *pci_dev, } + rte_kvargs_free(kvlist); return 0; err: @@ -6419,6 +6450,8 @@ static int bnxt_rep_port_probe(struct rte_pci_device *pci_dev, */ if (num_rep > 1) bnxt_pci_remove_dev_with_reps(backing_eth_dev); + rte_errno = -ret; + rte_kvargs_free(kvlist); return ret; } -- 2.21.1 (Apple Git-122.3)