mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2025-01-04 04:06:26 +00:00
PCI: of: Destroy changeset when adding PCI device node fails
Previously of_pci_make_dev_node() leaked a cset if it failed to create a
device node for the PCI device with of_changeset_create_node().
Destroy the cset if of_changeset_create_node() fails.
Fixes: 407d1a5192
("PCI: Create device tree node for bridge")
Link: https://lore.kernel.org/r/1696007417-42059-1-git-send-email-lizhi.hou@amd.com
Reported-by: Herve Codina <herve.codina@bootlin.com>
Closes: https://lore.kernel.org/all/20230911171319.495bb837@bootlin.com/
Signed-off-by: Lizhi Hou <lizhi.hou@amd.com>
[bhelgaas: commit log]
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Herve Codina <herve.codina@bootlin.com>
This commit is contained in:
parent
33efa29e82
commit
f699774047
@ -657,30 +657,33 @@ void of_pci_make_dev_node(struct pci_dev *pdev)
|
||||
|
||||
cset = kmalloc(sizeof(*cset), GFP_KERNEL);
|
||||
if (!cset)
|
||||
goto failed;
|
||||
goto out_free_name;
|
||||
of_changeset_init(cset);
|
||||
|
||||
np = of_changeset_create_node(cset, ppnode, name);
|
||||
if (!np)
|
||||
goto failed;
|
||||
np->data = cset;
|
||||
goto out_destroy_cset;
|
||||
|
||||
ret = of_pci_add_properties(pdev, cset, np);
|
||||
if (ret)
|
||||
goto failed;
|
||||
goto out_free_node;
|
||||
|
||||
ret = of_changeset_apply(cset);
|
||||
if (ret)
|
||||
goto failed;
|
||||
goto out_free_node;
|
||||
|
||||
np->data = cset;
|
||||
pdev->dev.of_node = np;
|
||||
kfree(name);
|
||||
|
||||
return;
|
||||
|
||||
failed:
|
||||
if (np)
|
||||
of_node_put(np);
|
||||
out_free_node:
|
||||
of_node_put(np);
|
||||
out_destroy_cset:
|
||||
of_changeset_destroy(cset);
|
||||
kfree(cset);
|
||||
out_free_name:
|
||||
kfree(name);
|
||||
}
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user