[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20260206220619.GA96887@bhelgaas>
Date: Fri, 6 Feb 2026 16:06:19 -0600
From: Bjorn Helgaas <helgaas@...nel.org>
To: Felix Gu <ustc.gu@...il.com>
Cc: Claudiu Beznea <claudiu.beznea.uj@...renesas.com>,
Lorenzo Pieralisi <lpieralisi@...nel.org>,
Krzysztof WilczyĆski <kwilczynski@...nel.org>,
Manivannan Sadhasivam <mani@...nel.org>,
Rob Herring <robh@...nel.org>, Bjorn Helgaas <bhelgaas@...gle.com>,
linux-pci@...r.kernel.org, linux-renesas-soc@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH] PCI: rzg3s-host: Fix device node reference leak in
rzg3s_pcie_host_parse_port()
On Wed, Feb 04, 2026 at 12:46:24AM +0800, Felix Gu wrote:
> In rzg3s_pcie_host_parse_port(), of_get_next_child() returns a device
> node with an incremented reference count that must be released with
> of_node_put(). The current code fails to call of_node_put() which
> causes a reference leak.
>
> Use the __free(device_node) attribute to ensure automatic cleanup when
> the variable goes out of scope.
>
> Fixes: 7ef502fb35b2 ("PCI: Add Renesas RZ/G3S host controller driver")
> Signed-off-by: Felix Gu <ustc.gu@...il.com>
Applied to pci/controller/rzg3s-host for v6.20, thanks!
It's close to the merge window, but only affects a single driver
that's pretty new, so if anything breaks it won't affect many people.
> ---
> drivers/pci/controller/pcie-rzg3s-host.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/pci/controller/pcie-rzg3s-host.c b/drivers/pci/controller/pcie-rzg3s-host.c
> index 5aa58638903f..2809112e6317 100644
> --- a/drivers/pci/controller/pcie-rzg3s-host.c
> +++ b/drivers/pci/controller/pcie-rzg3s-host.c
> @@ -1142,7 +1142,8 @@ static int rzg3s_pcie_resets_prepare_and_get(struct rzg3s_pcie_host *host)
>
> static int rzg3s_pcie_host_parse_port(struct rzg3s_pcie_host *host)
> {
> - struct device_node *of_port = of_get_next_child(host->dev->of_node, NULL);
> + struct device_node *of_port __free(device_node) =
> + of_get_next_child(host->dev->of_node, NULL);
> struct rzg3s_pcie_port *port = &host->port;
> int ret;
>
>
> ---
> base-commit: 193579fe01389bc21aff0051d13f24e8ea95b47d
> change-id: 20260204-rzg3s-bc7c27c80a89
>
> Best regards,
> --
> Felix Gu <ustc.gu@...il.com>
>
Powered by blists - more mailing lists