perf: hisi_pcie: Call pci_dev_put(pdev) only once in hisi_pcie_pmu_valid_requester_id()
PATCH 1/1 perf: hisi_pcie: Call pci_dev_put(pdev) only once in hisi_pcie_pmu_valid_requester_id()
From: Markus Elfring <[email protected]>
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 <[email protected]>
--- drivers/perf/hisilicon/hisi_pcie_pmu.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/perf/hisilicon/hisi_pcie_pmu.c +2 -4
@@ -290,12 +290,10 @@ static bool hisi_pcie_pmu_valid_requester_id(struct hisi_pcie_pmu *pcie_pmu, u32return 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