From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 0E6A4A0524 for ; Fri, 5 Feb 2021 12:37:25 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 097CE1889FC; Fri, 5 Feb 2021 12:37:25 +0100 (CET) Received: from mail-wm1-f48.google.com (mail-wm1-f48.google.com [209.85.128.48]) by mails.dpdk.org (Postfix) with ESMTP id B95621889F7 for ; Fri, 5 Feb 2021 12:37:23 +0100 (CET) Received: by mail-wm1-f48.google.com with SMTP id u14so5644026wmq.4 for ; Fri, 05 Feb 2021 03:37:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Jb8evYs8HN9B7AZUV1+K3Sujf7SUS2FvKUlP2zKf5a0=; b=Z0/ac25MZtu8xsbGXindFejOlzz4K0eJMN6OPfJqXutKrd4kLn5kUeGF+d6wVoAhMa ai8HpRkTme/LEoQjNnBzDmvVSTKePnze2hMdSN8vjQjn4RegV9JUp8cDmelFhqD2Mz5G S0siToV+KF/p6UniDIf+jkCvBepPUWI6o+1e1RDDa4EaotaJ62XRTuFN0JC8CGPhvym+ LAUBfUQMnj/si9aSz8SJ2kZfB599X+wJMa9F7QRmGiHCrJgCusngKnvmoHcJEPjAkFp/ E987L2e3afiE3qlDJE3ZVw/doFN/vPq8FQelcoJ57WK1nhZEuW7t2nvaAtWJyj53kU0E yJxQ== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=Jb8evYs8HN9B7AZUV1+K3Sujf7SUS2FvKUlP2zKf5a0=; b=dHZYUNeS5J1F6hbrtNg4OcfhzO2Y9gANjDX/JdS/XzHxH9kF5HPUppddmIE7gjPEEH CVtRSnnyEi7yoqAL704PH/8mKXAzT4mM9MrIThNp21KJsbStzsiBzpBjxT0jm84o8iMv J842xWcdLsfEKrUMtfQ9jLFEWn786ZJgF6wGKVaq1fq3NfMQbk5rJtQ71HGmjrbmJqXA BhDMwz6kMGskwhx7X6NMWXTrG4eamRo9vKgTSXvMAJCvHZiTR8V8pCVWkMSiGx26Ktqc mXzJvQgTGU9xTvWtUoqb8j5ay5oVjqvB7JgEqSqh0/AWhQy1gnw/vFhi5qE8+Rkxr56G yU0Q== X-Gm-Message-State: AOAM532yRDyTOazF6as43K0oAlsu1VpY3FKtmsC5rsF7U+ffqf8jz7el I4X5Sh+qXHwKWiOtqLWR0i0= X-Google-Smtp-Source: ABdhPJyFyHFBridY4o/B3x5QSLI0LnmuCbvTGDAsQvKmYb9w5FgSfne8ykqKaaWHbsGgPNTXtNQ71g== X-Received: by 2002:a05:600c:35c5:: with SMTP id r5mr3226757wmq.81.1612525043473; Fri, 05 Feb 2021 03:37:23 -0800 (PST) Received: from localhost ([88.98.246.218]) by smtp.gmail.com with ESMTPSA id w15sm11384983wrp.15.2021.02.05.03.37.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Feb 2021 03:37:22 -0800 (PST) From: luca.boccassi@gmail.com To: Michael Baum Cc: Matan Azrad , David Marchand , dpdk stable Date: Fri, 5 Feb 2021 11:18:34 +0000 Message-Id: <20210205111920.1272063-228-luca.boccassi@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210205111920.1272063-1-luca.boccassi@gmail.com> References: <20210205111920.1272063-1-luca.boccassi@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-stable] patch 'net/mlx4: fix handling of probing failure' has been queued to stable release 20.11.1 X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Sender: "stable" Hi, FYI, your patch has been queued to stable release 20.11.1 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 02/07/21. So please shout if anyone has objections. Also note that after the patch there's a diff of the upstream commit vs the patch applied to the branch. This will indicate if there was any rebasing needed to apply to the stable branch. If there were code changes for rebasing (ie: not only metadata diffs), please double check that the rebase was correctly done. Queued patches are on a temporary branch at: https://github.com/bluca/dpdk-stable This queued commit can be viewed at: https://github.com/bluca/dpdk-stable/commit/7d169ad52938deea81d75ae6b7f566276a19a2a1 each Thanks. Luca Boccassi --- >From 7d169ad52938deea81d75ae6b7f566276a19a2a1 Mon Sep 17 00:00:00 2001 From: Michael Baum Date: Wed, 20 Jan 2021 08:14:51 +0000 Subject: [PATCH] net/mlx4: fix handling of probing failure [ upstream commit bcf58b64dafe1a298ee5de2ae018876d2e5c1362 ] In mlx4 PCI probing, there are some validations for the Ethernet device configuration. >From each PCI device the function creates one or two Ethernet devices. When one of validations fails during the creation of the second device, the first device is not freed what caused a memory leak. Free it. Fixes: 7fae69eeff13 ("mlx4: new poll mode driver") Signed-off-by: Michael Baum Acked-by: Matan Azrad Tested-by: David Marchand --- drivers/net/mlx4/mlx4.c | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/drivers/net/mlx4/mlx4.c b/drivers/net/mlx4/mlx4.c index 7460afa859..495b4fc8bd 100644 --- a/drivers/net/mlx4/mlx4.c +++ b/drivers/net/mlx4/mlx4.c @@ -766,6 +766,7 @@ mlx4_pci_probe(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev) struct ibv_context *attr_ctx = NULL; struct ibv_device_attr device_attr; struct ibv_device_attr_ex device_attr_ex; + struct rte_eth_dev *prev_dev = NULL; struct mlx4_conf conf = { .ports.present = 0, .mr_ext_memseg_en = 1, @@ -880,7 +881,7 @@ mlx4_pci_probe(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev) ERROR("can not attach rte ethdev"); rte_errno = ENOMEM; err = rte_errno; - goto error; + goto err_secondary; } priv = eth_dev->data->dev_private; if (!priv->verbs_alloc_ctx.enabled) { @@ -889,24 +890,24 @@ mlx4_pci_probe(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev) " from Verbs"); rte_errno = ENOTSUP; err = rte_errno; - goto error; + goto err_secondary; } eth_dev->device = &pci_dev->device; eth_dev->dev_ops = &mlx4_dev_sec_ops; err = mlx4_proc_priv_init(eth_dev); if (err) - goto error; + goto err_secondary; /* Receive command fd from primary process. */ err = mlx4_mp_req_verbs_cmd_fd(eth_dev); if (err < 0) { err = rte_errno; - goto error; + goto err_secondary; } /* Remap UAR for Tx queues. */ err = mlx4_tx_uar_init_secondary(eth_dev, err); if (err) { err = rte_errno; - goto error; + goto err_secondary; } /* * Ethdev pointer is still required as input since @@ -918,7 +919,14 @@ mlx4_pci_probe(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev) claim_zero(mlx4_glue->close_device(ctx)); rte_eth_copy_pci_info(eth_dev, pci_dev); rte_eth_dev_probing_finish(eth_dev); + prev_dev = eth_dev; continue; +err_secondary: + claim_zero(mlx4_glue->close_device(ctx)); + rte_eth_dev_release_port(eth_dev); + if (prev_dev) + rte_eth_dev_release_port(prev_dev); + break; } /* Check port status. */ err = mlx4_glue->query_port(ctx, port, &port_attr); @@ -1093,6 +1101,7 @@ mlx4_pci_probe(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev) priv, mem_event_cb); rte_rwlock_write_unlock(&mlx4_shared_data->mem_event_rwlock); rte_eth_dev_probing_finish(eth_dev); + prev_dev = eth_dev; continue; port_error: rte_free(priv); @@ -1107,14 +1116,10 @@ port_error: eth_dev->data->mac_addrs = NULL; rte_eth_dev_release_port(eth_dev); } + if (prev_dev) + mlx4_dev_close(prev_dev); break; } - /* - * XXX if something went wrong in the loop above, there is a resource - * leak (ctx, pd, priv, dpdk ethdev) but we can do nothing about it as - * long as the dpdk does not provide a way to deallocate a ethdev and a - * way to enumerate the registered ethdevs to free the previous ones. - */ error: if (attr_ctx) claim_zero(mlx4_glue->close_device(attr_ctx)); -- 2.29.2 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2021-02-05 11:18:39.233932536 +0000 +++ 0228-net-mlx4-fix-handling-of-probing-failure.patch 2021-02-05 11:18:29.202698652 +0000 @@ -1 +1 @@ -From bcf58b64dafe1a298ee5de2ae018876d2e5c1362 Mon Sep 17 00:00:00 2001 +From 7d169ad52938deea81d75ae6b7f566276a19a2a1 Mon Sep 17 00:00:00 2001 @@ -5,0 +6,2 @@ +[ upstream commit bcf58b64dafe1a298ee5de2ae018876d2e5c1362 ] + @@ -16 +17,0 @@ -Cc: stable@dpdk.org @@ -26 +27 @@ -index f520d32456..284dcb9dd0 100644 +index 7460afa859..495b4fc8bd 100644