mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Marek Vasut <marek.vasut@mailbox.org>
To: Yuho Choi <dbgh9129@gmail.com>,
	marek.vasut+renesas@mailbox.org,
	yoshihiro.shimoda.uh@renesas.com, lpieralisi@kernel.org,
	kwilczynski@kernel.org, mani@kernel.org, bhelgaas@google.com,
	geert+renesas@glider.be, magnus.damm@gmail.com
Cc: robh@kernel.org, linux-pci@vger.kernel.org,
	linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v1] PCI: rcar: Release temporary device tree node reference
Date: Sun, 2 Aug 2026 04:20:19 +0200	[thread overview]
Message-ID: <5caff653-3681-4025-9be0-946778d33f8e@mailbox.org> (raw)
In-Reply-To: <20260801233841.469826-1-dbgh9129@gmail.com>

On 8/2/26 1:38 AM, Yuho Choi wrote:
> of_find_matching_node() returns a referenced node even when it is used
> only as a boolean test. Keep the result in a scoped cleanup variable
> so the reference is released after the match check.
> 
> Fixes: a115b1bd3af0 ("PCI: rcar: Add L1 link state fix into data abort hook")
> Signed-off-by: Yuho Choi <dbgh9129@gmail.com>
> ---
>   drivers/pci/controller/pcie-rcar-host.c | 5 ++++-
>   1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/pci/controller/pcie-rcar-host.c b/drivers/pci/controller/pcie-rcar-host.c
> index cd9171eebc28..7ed1bc0732ce 100644
> --- a/drivers/pci/controller/pcie-rcar-host.c
> +++ b/drivers/pci/controller/pcie-rcar-host.c
> @@ -1122,7 +1122,10 @@ static const struct of_device_id rcar_pcie_abort_handler_of_match[] __initconst
>   
>   static int __init rcar_pcie_init(void)
>   {
> -	if (of_find_matching_node(NULL, rcar_pcie_abort_handler_of_match)) {
> +	struct device_node *np __free(device_node) =
> +		of_find_matching_node(NULL, rcar_pcie_abort_handler_of_match);
> +
> +	if (np) {
>   #ifdef CONFIG_ARM_LPAE
>   		hook_fault_code(17, rcar_pcie_aarch32_abort_handler, SIGBUS, 0,
>   				"asynchronous external abort");

How about this simpler version:

"
diff --git a/drivers/pci/controller/pcie-rcar-host.c 
b/drivers/pci/controller/pcie-rcar-host.c
index 213028052aa58..a4a42e435947f 100644
--- a/drivers/pci/controller/pcie-rcar-host.c
+++ b/drivers/pci/controller/pcie-rcar-host.c
@@ -1123,7 +1123,9 @@ static const struct of_device_id 
rcar_pcie_abort_handler_of_match[] __initconst

  static int __init rcar_pcie_init(void)
  {
-       if (of_find_matching_node(NULL, rcar_pcie_abort_handler_of_match)) {
+       struct device_node *np = of_find_matching_node(NULL, 
rcar_pcie_abort_handler_of_match);
+       if (np) {
+               of_node_put(np);
  #ifdef CONFIG_ARM_LPAE
                 hook_fault_code(17, rcar_pcie_aarch32_abort_handler, 
SIGBUS, 0,
                                 "asynchronous external abort");
"

Also, and this is more of a question for DT maintainers, would it make 
sense to introduce of_find_matching_node_and_match() variant called e.g. 
of_test_matching_node_exists() which would return boolean and would NOT 
call of_node_get() on the matched node in the first place, and then use 
it here ?

      reply	other threads:[~2026-08-02  3:35 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-01 23:38 Yuho Choi
2026-08-02  2:20 ` Marek Vasut [this message]

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=5caff653-3681-4025-9be0-946778d33f8e@mailbox.org \
    --to=marek.vasut@mailbox.org \
    --cc=bhelgaas@google.com \
    --cc=dbgh9129@gmail.com \
    --cc=geert+renesas@glider.be \
    --cc=kwilczynski@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=lpieralisi@kernel.org \
    --cc=magnus.damm@gmail.com \
    --cc=mani@kernel.org \
    --cc=marek.vasut+renesas@mailbox.org \
    --cc=robh@kernel.org \
    --cc=yoshihiro.shimoda.uh@renesas.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®