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 71DD242DA6 for ; Sat, 15 Jul 2023 00:35:15 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 6A46842BAC; Sat, 15 Jul 2023 00:35:15 +0200 (CEST) Received: from mail-wr1-f52.google.com (mail-wr1-f52.google.com [209.85.221.52]) by mails.dpdk.org (Postfix) with ESMTP id CE4EA40DFB for ; Sat, 15 Jul 2023 00:35:14 +0200 (CEST) Received: by mail-wr1-f52.google.com with SMTP id ffacd0b85a97d-316f4abb1e1so51947f8f.3 for ; Fri, 14 Jul 2023 15:35:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1689374114; x=1691966114; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=1lBaLdIDUN0I5DeD8awh9q+poSxVx3ovAofkKx5Iwxc=; b=pG6RftwMegwQg7UGhEw3pi/4EEKOIcCUTSBeEL+zNdUbkWMiWtptg+0RexaDTgAqZs Fpzdbmp/H/TaiY8zk2ve2G3W+eo+jNBW/d1N5ILHD3DM7JU0Gh/aVtoJJ9HvbtSc4/3f KzbYrOUnlpDAkZuabz6DMzJmxuMZYpOfTLfofTvMbpM8Pr4vgQ+f5Kpm4hrI5WkVDEE7 UUcRxckojTmKILBrcbTpSSvb9Aw2JT0MtxCF+HsxDi1USlBzuUDyPLuHEkYTULGWhqNj 3+9RRoRZs/p/oDHYQhn8SfiX4zaqBFyvRuCbmpsomEqgVr8OaIjEK+ZiXJQuT5mqlMlA iLCg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689374114; x=1691966114; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=1lBaLdIDUN0I5DeD8awh9q+poSxVx3ovAofkKx5Iwxc=; b=acnhzbGwaRuDS2GRRHtuQR0SZMAAoPu9sFaT6YqK8ZhD7YpWfJep5K+KLumJr2SYeZ 98c/pD5cYf4gHmoBM7J4dIJ4u4jFQ1Ik6xJOtY/WVHNALgUxZoZsvwOUM4cvbjW6NCiF wllR0yZb2oxEcVVAmcnitd4Ad0dBYGKmqunZVtLhkBonQ83XtS6ktZVJiwvZYlOYxI9z o3/wv8lwdtdpQYnpje4m9M56Wwqk0BurobEhVrM96W4/LJbm6GZtNodC4/6gw4C9nSPK wBpE0OA9t80FfnvEotIdaRKrnkxATgi7NumqxpGTJXBXu64TCEDjarlQaVyHtJUlNYiU aCZQ== X-Gm-Message-State: ABy/qLYn/ghBHNR+eE0JF4nD1cXN/+bTBkqzEuOjb291+owgPjrPdu+s hPMVjzUNvmzfVR4tu0T9buQ= X-Google-Smtp-Source: APBJJlEV7ZZAeuZNweGvE3OOOk6ZPjWoBfMsiPINjBI17yxavmsSV1YdkCPByXvj+RwfGUpaRsGZVA== X-Received: by 2002:a5d:4564:0:b0:306:46c4:d313 with SMTP id a4-20020a5d4564000000b0030646c4d313mr5013915wrc.28.1689374114538; Fri, 14 Jul 2023 15:35:14 -0700 (PDT) Received: from localhost ([2a01:4b00:d307:1000:f1d3:eb5e:11f4:a7d9]) by smtp.gmail.com with ESMTPSA id j16-20020a5d4650000000b0031435c2600esm11996452wrs.79.2023.07.14.15.35.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Jul 2023 15:35:14 -0700 (PDT) From: luca.boccassi@gmail.com To: Kaiyu Zhang Cc: Chengwen Feng , Ferruh Yigit , dpdk stable Subject: patch 'ethdev: fix potential leak in PCI probing helper' has been queued to stable release 20.11.9 Date: Fri, 14 Jul 2023 23:34:37 +0100 Message-Id: <20230714223447.1092828-8-luca.boccassi@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230714223447.1092828-1-luca.boccassi@gmail.com> References: <20230628141046.2145871-22-luca.boccassi@gmail.com> <20230714223447.1092828-1-luca.boccassi@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 Hi, FYI, your patch has been queued to stable release 20.11.9 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 07/16/23. 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/a981ef39159d96f6e9d72ea5986265b992bbfd74 Thanks. Luca Boccassi --- >From a981ef39159d96f6e9d72ea5986265b992bbfd74 Mon Sep 17 00:00:00 2001 From: Kaiyu Zhang Date: Tue, 11 Jul 2023 01:18:09 +0000 Subject: [PATCH] ethdev: fix potential leak in PCI probing helper [ upstream commit 1f00a6a037040a7c6ba883e2c312894c6ebc4c32 ] Sanity check is performed after a rte_eth_dev object is allocated. The object is not freed if the check fails, though in the current reality this never happens, but it's better programming paradigm to move the quick check up front to the start of rte_eth_dev_pci_generic_probe(). Fixes: dcd5c8112bc3 ("ethdev: add PCI driver helpers") Signed-off-by: Kaiyu Zhang Reviewed-by: Chengwen Feng Reviewed-by: Ferruh Yigit --- lib/librte_ethdev/rte_ethdev_pci.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/librte_ethdev/rte_ethdev_pci.h b/lib/librte_ethdev/rte_ethdev_pci.h index d015697e21..d5ec47f283 100644 --- a/lib/librte_ethdev/rte_ethdev_pci.h +++ b/lib/librte_ethdev/rte_ethdev_pci.h @@ -126,6 +126,9 @@ rte_eth_dev_pci_generic_probe(struct rte_pci_device *pci_dev, struct rte_eth_dev *eth_dev; int ret; + if (*dev_init == NULL) + return -EINVAL; + eth_dev = rte_eth_dev_pci_allocate(pci_dev, private_data_size); if (!eth_dev) return -ENOMEM; -- 2.39.2 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2023-07-14 23:33:08.828659111 +0100 +++ 0008-ethdev-fix-potential-leak-in-PCI-probing-helper.patch 2023-07-14 23:33:08.487305115 +0100 @@ -1 +1 @@ -From 1f00a6a037040a7c6ba883e2c312894c6ebc4c32 Mon Sep 17 00:00:00 2001 +From a981ef39159d96f6e9d72ea5986265b992bbfd74 Mon Sep 17 00:00:00 2001 @@ -5,0 +6,2 @@ +[ upstream commit 1f00a6a037040a7c6ba883e2c312894c6ebc4c32 ] + @@ -14 +15,0 @@ -Cc: stable@dpdk.org @@ -20,21 +21,8 @@ - .mailmap | 1 + - lib/ethdev/ethdev_pci.h | 9 +++++---- - 2 files changed, 6 insertions(+), 4 deletions(-) - -diff --git a/.mailmap b/.mailmap -index d200f36339..6c28ea798d 100644 ---- a/.mailmap -+++ b/.mailmap -@@ -698,6 +698,7 @@ Kai Ji - Kaijun Zeng - Kaisen You - Kaiwen Deng -+Kaiyu Zhang - Kalesh AP - Kamalakannan R - Kamalakshitha Aligeri -diff --git a/lib/ethdev/ethdev_pci.h b/lib/ethdev/ethdev_pci.h -index 94b8fba5d7..320e3e0093 100644 ---- a/lib/ethdev/ethdev_pci.h -+++ b/lib/ethdev/ethdev_pci.h -@@ -126,12 +126,13 @@ rte_eth_dev_pci_generic_probe(struct rte_pci_device *pci_dev, + lib/librte_ethdev/rte_ethdev_pci.h | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/lib/librte_ethdev/rte_ethdev_pci.h b/lib/librte_ethdev/rte_ethdev_pci.h +index d015697e21..d5ec47f283 100644 +--- a/lib/librte_ethdev/rte_ethdev_pci.h ++++ b/lib/librte_ethdev/rte_ethdev_pci.h +@@ -126,6 +126,9 @@ rte_eth_dev_pci_generic_probe(struct rte_pci_device *pci_dev, @@ -44,10 +32,2 @@ -- eth_dev = rte_eth_dev_pci_allocate(pci_dev, private_data_size); -- if (!eth_dev) -- return -ENOMEM; -- - if (*dev_init == NULL) - return -EINVAL; -+ -+ eth_dev = rte_eth_dev_pci_allocate(pci_dev, private_data_size); -+ if (!eth_dev) -+ return -ENOMEM; ++ if (*dev_init == NULL) ++ return -EINVAL; @@ -55,3 +35,3 @@ - ret = dev_init(eth_dev); - if (ret) - rte_eth_dev_release_port(eth_dev); + eth_dev = rte_eth_dev_pci_allocate(pci_dev, private_data_size); + if (!eth_dev) + return -ENOMEM;