lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-ID: <2f84f558-3f65-4c09-89b8-485830b98654@web.de>
Date: Mon, 23 Sep 2024 21:28:21 +0200
From: Markus Elfring <Markus.Elfring@....de>
To: linux-arm-kernel@...ts.infradead.org, kernel-janitors@...r.kernel.org,
 John Garry <john.garry@...wei.com>,
 Jonathan Cameron <jonathan.cameron@...wei.com>,
 Krzysztof WilczyƄski <kw@...ux.com>,
 Mark Rutland <mark.rutland@....com>, Qi Liu <liuqi115@...wei.com>,
 Shaokun Zhang <zhangshaokun@...ilicon.com>, Will Deacon <will@...nel.org>,
 Yicong Yang <yangyicong@...ilicon.com>
Cc: LKML <linux-kernel@...r.kernel.org>
Subject: [PATCH] perf: hisi_pcie: Call pci_dev_put(pdev) only once in
 hisi_pcie_pmu_valid_requester_id()

From: Markus Elfring <elfring@...rs.sourceforge.net>
Date: Mon, 23 Sep 2024 21:17:45 +0200

A pci_dev_put(pdev) call was immediately used after a pointer check
for a pcie_find_root_port() call in this function implementation.
Thus call such a function only once instead directly before the check.

This issue was transformed by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@...rs.sourceforge.net>
---
 drivers/perf/hisilicon/hisi_pcie_pmu.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/perf/hisilicon/hisi_pcie_pmu.c b/drivers/perf/hisilicon/hisi_pcie_pmu.c
index c5394d007b61..5ff1c47d68ad 100644
--- a/drivers/perf/hisilicon/hisi_pcie_pmu.c
+++ b/drivers/perf/hisilicon/hisi_pcie_pmu.c
@@ -290,12 +290,10 @@ static bool hisi_pcie_pmu_valid_requester_id(struct hisi_pcie_pmu *pcie_pmu, u32
 		return false;

 	root_port = pcie_find_root_port(pdev);
-	if (!root_port) {
-		pci_dev_put(pdev);
+	pci_dev_put(pdev);
+	if (!root_port)
 		return false;
-	}

-	pci_dev_put(pdev);
 	rp_bdf = pci_dev_id(root_port);
 	return rp_bdf >= pcie_pmu->bdf_min && rp_bdf <= pcie_pmu->bdf_max;
 }
--
2.46.1


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ