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 CE3B4A04DD; Wed, 21 Oct 2020 16:04:27 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 8261DAA1B; Wed, 21 Oct 2020 16:04:25 +0200 (CEST) Received: from mail-ot1-f65.google.com (mail-ot1-f65.google.com [209.85.210.65]) by dpdk.org (Postfix) with ESMTP id A96D4AA15 for ; Wed, 21 Oct 2020 16:04:23 +0200 (CEST) Received: by mail-ot1-f65.google.com with SMTP id h62so1893987oth.9 for ; Wed, 21 Oct 2020 07:04:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=F8AOtROq+GlXAhiL9oE4H2ffDXYpwE30qbIOk6SwB70=; b=g3B32AbgsvQ6zpnlKVtTJcmNpwmUhIYUNKO2pc4UZLrD7yGYL+d9aRa4TCMjTUemVa Ly/ge39X2DpfIY9TfOWLCaOogCEwlJ6Yuejc6b3OlyozUDAh/lt+PSsP0eYcntDGaAFM MIANOWDmGQy57mxZdrmmYhSDt4lLXVSLnHl3A= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=F8AOtROq+GlXAhiL9oE4H2ffDXYpwE30qbIOk6SwB70=; b=tpqgYLe1S68ziG8UCTfCuUdOL3UbxkRPoIfXRFnaOHnarM2pw2aF+vhkdWQhSSc7k2 RTVV8jZNUmk4IDl3j5MGTpB5RFWcLdMBm/zJ4QcEUyV+eLzsKcuwyAlrRH1TZDfrCH6H Xi9LG1W7k9Twc4NEfz6EY9gNOuemzEmHdJOxZzsFx0Cnq24pUDodmOll9Q4CFD9hRsZZ b28E2TjU784BxwGDD9o3t/JSLQ1f1ty9HHgRFgql+WkN4D+Iqw0vbKmSB53gDYjEN7rX 3Tyrz0LtpSrzzwcLTvEp0HZKDUUX8FdQmFYIcAnEFSYDfNoz7LWg9XFGIEfAk5tFCZGw Fzww== X-Gm-Message-State: AOAM533U5fivZHPSW2HvoJbepyL8B3oJ2B2cc3wGlM+qr1bhp/JULxxe Jnd5wZMDOXeakKjOXd3D/OCRco7isgh5LKk8tN92MvaG/Fpx3S1U X-Google-Smtp-Source: ABdhPJyxAmK2o1QT269CYezLDO++Wvt0zac8G75Pi+uaNpSdHqBlJiev31syoEld7cBlrjHrr4G8wkF/YMAOraas3hE= X-Received: by 2002:a9d:f67:: with SMTP id 94mr2931964ott.154.1603289061612; Wed, 21 Oct 2020 07:04:21 -0700 (PDT) MIME-Version: 1.0 References: <20201021060032.23833-1-ajit.khaparde@broadcom.com> In-Reply-To: <20201021060032.23833-1-ajit.khaparde@broadcom.com> From: Ajit Khaparde Date: Wed, 21 Oct 2020 07:04:05 -0700 Message-ID: To: dpdk-dev Cc: Kalesh AP Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.15 Subject: Re: [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" On Tue, Oct 20, 2020 at 11:00 PM Ajit Khaparde wrote: > > 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 Patch applied to dpdk-next-net-brcm. > --- > 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) >