* [PATCH] perf: hisi_pcie: Call pci_dev_put(pdev) only once in hisi_pcie_pmu_valid_requester_id()
@ 2024-09-23 19:28 Markus Elfring
0 siblings, 0 replies; only message in thread
From: Markus Elfring @ 2024-09-23 19:28 UTC (permalink / raw)
To: linux-arm-kernel, kernel-janitors, John Garry, Jonathan Cameron,
Krzysztof Wilczyński, Mark Rutland, Qi Liu, Shaokun Zhang,
Will Deacon, Yicong Yang
Cc: LKML
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(-)
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
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2024-09-23 19:29 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-09-23 19:28 [PATCH] perf: hisi_pcie: Call pci_dev_put(pdev) only once in hisi_pcie_pmu_valid_requester_id() Markus Elfring
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®