Commit e43e2aa5 authored by Felix Gu's avatar Felix Gu Committed by Bjorn Helgaas
Browse files

PCI: rzg3s-host: Fix device node reference leak in rzg3s_pcie_host_parse_port()



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: 7ef502fb ("PCI: Add Renesas RZ/G3S host controller driver")
Signed-off-by: default avatarFelix Gu <ustc.gu@gmail.com>
Signed-off-by: default avatarBjorn Helgaas <bhelgaas@google.com>
Tested-by: default avatarClaudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
Reviewed-by: default avatarClaudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
Acked-by: default avatarManivannan Sadhasivam <mani@kernel.org>
Link: https://patch.msgid.link/20260204-rzg3s-v1-1-142bc81c3312@gmail.com
parent 62d49112
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -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;