mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Markus Elfring <Markus.Elfring@web.de>
To: linux-arm-kernel@lists.infradead.org,
	kernel-janitors@vger.kernel.org,
	"John Garry" <john.garry@huawei.com>,
	"Jonathan Cameron" <jonathan.cameron@huawei.com>,
	"Krzysztof Wilczyński" <kw@linux.com>,
	"Mark Rutland" <mark.rutland@arm.com>,
	"Qi Liu" <liuqi115@huawei.com>,
	"Shaokun Zhang" <zhangshaokun@hisilicon.com>,
	"Will Deacon" <will@kernel.org>,
	"Yicong Yang" <yangyicong@hisilicon.com>
Cc: LKML <linux-kernel@vger.kernel.org>
Subject: [PATCH] perf: hisi_pcie: Call pci_dev_put(pdev) only once in hisi_pcie_pmu_valid_requester_id()
Date: Mon, 23 Sep 2024 21:28:21 +0200	[thread overview]
Message-ID: <2f84f558-3f65-4c09-89b8-485830b98654@web.de> (raw)

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


                 reply	other threads:[~2024-09-23 19:29 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2f84f558-3f65-4c09-89b8-485830b98654@web.de \
    --to=markus.elfring@web.de \
    --cc=john.garry@huawei.com \
    --cc=jonathan.cameron@huawei.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=kw@linux.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=liuqi115@huawei.com \
    --cc=mark.rutland@arm.com \
    --cc=will@kernel.org \
    --cc=yangyicong@hisilicon.com \
    --cc=zhangshaokun@hisilicon.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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®