diff mbox series

perf: hisi_pcie: Call pci_dev_put(pdev) only once in hisi_pcie_pmu_valid_requester_id()

Message ID 2f84f558-3f65-4c09-89b8-485830b98654@web.de (mailing list archive)
State New, archived
Headers show
Series perf: hisi_pcie: Call pci_dev_put(pdev) only once in hisi_pcie_pmu_valid_requester_id() | expand

Commit Message

Markus Elfring Sept. 23, 2024, 7:28 p.m. UTC
From: Markus Elfring <elfring@users.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@users.sourceforge.net>
---
 drivers/perf/hisilicon/hisi_pcie_pmu.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

--
2.46.1
diff mbox series

Patch

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;
 }