From patchwork Mon Sep 23 19:28:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Elfring X-Patchwork-Id: 13809949 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 91D4FCF9C6F for ; Mon, 23 Sep 2024 19:30:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: Content-Type:Subject:From:Cc:To:MIME-Version:Date:Message-ID:Reply-To: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=djbkrGXRtHq7orMC8Q8l8m1TWgw6GsJVQydsMLaFwc8=; b=diVTwzXiEYFf4ozSQoceR7q8X9 uZf3TghXF6ioTVz1FNU/XhyNT/I6+9nN8n5jzS/ANFd25li18Jpa949L8hK71MixWvFjv9ZJcMkNU h8kwhE/WfN82P3pkOYJdeW43MPeMSzMtkVEPumE8cPg0240TuESaw8vcQ4R4T3lv4KnbnivukCAjU BusFH5Tup67abmwlPKsIckJoeGf98dZr3+WigXOtoncMtTesl3GaQJ2UgjDVk2lJYe4q5HzDN4Hs6 MP4NSrS3s9lNpT/wwiMw0i62EOxUIB8jNd/KwD588f0dOMxf3mdaa1Kn7sE4F5JO5Y9SgTHESCRtk VUelht9Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1ssolD-00000000Mq9-2D82; Mon, 23 Sep 2024 19:30:15 +0000 Received: from mout.web.de ([212.227.17.11]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1ssok5-00000000MlE-3pg7 for linux-arm-kernel@lists.infradead.org; Mon, 23 Sep 2024 19:29:07 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=web.de; s=s29768273; t=1727119708; x=1727724508; i=markus.elfring@web.de; bh=djbkrGXRtHq7orMC8Q8l8m1TWgw6GsJVQydsMLaFwc8=; h=X-UI-Sender-Class:Message-ID:Date:MIME-Version:To:Cc:From: Subject:Content-Type:Content-Transfer-Encoding:cc: content-transfer-encoding:content-type:date:from:message-id: mime-version:reply-to:subject:to; b=lzQRuxGVprEOZcwfDsVMIynvys+4FfyL3XTOSrVRMsOwJtmcSqEK76QVwrttUD6A n6lrbaR3amC3BWVN7oerHBdMohrRuPMMMOd1mgXoYGjeaUmXd1Ae9fx/hKAlfpTRb XOm/8UMZBKUHKj1rCbpkmLLTWbS0hekWDPp3TLRG7qII5vEobMN0iO/NizqsAxuvk gf1qb55bLwUn3Uhb2U6LegMv3//Ymaxqw8OvvjfPklosbcumjBlsYdc4Do6f4Bn2I 7J/+GN3D3NnnfQBddLZljEr7jjcmYI1gXACn0ADa5uO4UGXvxVyu4b6LIhVCeeWNp fA6GKSVY3Y8gt7nJ/Q== X-UI-Sender-Class: 814a7b36-bfc1-4dae-8640-3722d8ec6cd6 Received: from [192.168.178.21] ([94.31.90.95]) by smtp.web.de (mrweb105 [213.165.67.124]) with ESMTPSA (Nemesis) id 1Mx0Mr-1rzutD2pPH-00ytzp; Mon, 23 Sep 2024 21:28:28 +0200 Message-ID: <2f84f558-3f65-4c09-89b8-485830b98654@web.de> Date: Mon, 23 Sep 2024 21:28:21 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird To: linux-arm-kernel@lists.infradead.org, kernel-janitors@vger.kernel.org, John Garry , Jonathan Cameron , =?utf-8?q?Krzysztof_Wilczy?= =?utf-8?q?=C5=84ski?= , Mark Rutland , Qi Liu , Shaokun Zhang , Will Deacon , Yicong Yang Content-Language: en-GB Cc: LKML From: Markus Elfring Subject: [PATCH] perf: hisi_pcie: Call pci_dev_put(pdev) only once in hisi_pcie_pmu_valid_requester_id() X-Provags-ID: V03:K1:8duds6sd5ZmSPqOeRJ4uuEaJhMIYGVj1GgAfwEil8eQ74MyJXfh MC6aBHbnX/dGzeLx9nblCjnSYQgWJSgBXhzGPl/WUXcEujJFDi5sVG6eW5C1yyNMhK8Z/ak aIMqM7Ae2nyw2tHM9nTQROA3hydHPbvcaDXHBwgoIRJiT8s81rKeEDV5GXPzXyc+ESQp4rP 74AKEvbpWTiirItL+FLhQ== UI-OutboundReport: notjunk:1;M01:P0:irXljewrlso=;jJb4CF2hUg2EL37RJH0k8OceEBq dPDz0WsyioqT8Y9KZgl0GxFuhw3FSaYbkLM8oLzbo0g6EwcfaELASDTpdFkruMdkt3VTnwc8E 2wIJneo4C54t4wl0k+//R7HcC2dtfHWEuPasUNxKp/wFhgTf524eGG6Sw1oggTmk8/WWI3Wz+ AeqIFb6BXy3sz4TWnP4OCR155A5mxnFz7u3hjGoM/lbQBu07nUTcoSj7eHORa4i9yO2J4CDIl JQZnR7y/masgPFbZQ4Tp0vGnEAEFCmhRqLNg8OnutHPvLQYvMlK0VNIWrgXT1BZpkuov/i9B5 D1tbSc96dAM0NLPC6UazhltrNC0YIe9dG5TLpxGlZireG2Rd6qI7lL3Yqp+7uNozlPjHf0vsg TN5ryWI0qa1ZjpCS1ODAcdXZ9LLICOXsIwlm9678YnuIubtjdZ13h0VQvwznzQFFmluzHnxiM LnaQ2vy3AT+NpiTP/uT62xX87oW5oMjaHW1HYOS5xAmJGg//XJ5kAKbykbgYFvGFKEydEaKi9 8dxiOzjFceQU33eBj3OUFmWie4RG1ArR3sVuhQOZhYgHgN+eXU340yril4WOmkyVrTz+CkSyk C2qWn8eVjLZFsRStAbCFZ9ngOJZym7mVT/o6asaOHnjt0qoyc0wUiAbo6GlOBsH5euEO8xz3V ysMp96rdpdWoYaVso1w7n49B4l7F/c/Or2O9kliDgPpZeUm8Hz0e0lvO/J2u4FDpyrD0jAppR JCVA7tRgNUV8w0IbC2pvs4fKR7nLX+AY64YuhVyl9mlBgY3wWah3u1+UVuLDXaycfcv5nb9eW TWs3m7v3CskgHq1AlWsjZ0/g== X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240923_122906_270707_C87C3B63 X-CRM114-Status: UNSURE ( 7.72 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Markus Elfring 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 --- drivers/perf/hisilicon/hisi_pcie_pmu.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) -- 2.46.1 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; }