Skip to content

Commit e43e2aa

Browse files
outman119bjorn-helgaas
authored andcommitted
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: 7ef502f ("PCI: Add Renesas RZ/G3S host controller driver") Signed-off-by: Felix Gu <ustc.gu@gmail.com> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com> Tested-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com> Reviewed-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com> Acked-by: Manivannan Sadhasivam <mani@kernel.org> Link: https://patch.msgid.link/20260204-rzg3s-v1-1-142bc81c3312@gmail.com
1 parent 62d4911 commit e43e2aa

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

drivers/pci/controller/pcie-rzg3s-host.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1142,7 +1142,8 @@ static int rzg3s_pcie_resets_prepare_and_get(struct rzg3s_pcie_host *host)
11421142

11431143
static int rzg3s_pcie_host_parse_port(struct rzg3s_pcie_host *host)
11441144
{
1145-
struct device_node *of_port = of_get_next_child(host->dev->of_node, NULL);
1145+
struct device_node *of_port __free(device_node) =
1146+
of_get_next_child(host->dev->of_node, NULL);
11461147
struct rzg3s_pcie_port *port = &host->port;
11471148
int ret;
11481149

0 commit comments

Comments
 (0)