[PATCH v2] misc: lan966x_pci: depopulate children on populate failure
From: Pengpeng Hou
Date: Mon Jun 22 2026 - 11:39:18 EST
lan966x_pci_probe() may create child platform devices before
of_platform_default_populate() returns an error. The error path unloads
the overlay immediately, but it does not depopulate any children that
were already created from overlay nodes.
Depopulate the children before unloading the overlay when population
fails.
Signed-off-by: Pengpeng Hou <pengpeng@xxxxxxxxxxx>
Reviewed-by: Herve Codina <herve.codina@xxxxxxxxxxx>
Reported-by: kernel test robot <lkp@xxxxxxxxx>
Closes: https://lore.kernel.org/oe-kbuild-all/202606161724.uAEP4nTA-lkp@xxxxxxxxx/
---
Changes since v1:
- Avoid adding an unused error label by depopulating inline before jumping
to the existing overlay unload label.
drivers/misc/lan966x_pci.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/misc/lan966x_pci.c b/drivers/misc/lan966x_pci.c
index 9e63076d3de0..0a2945f5f4d4 100644
--- a/drivers/misc/lan966x_pci.c
+++ b/drivers/misc/lan966x_pci.c
@@ -178,8 +178,10 @@ static int lan966x_pci_probe(struct pci_dev *pdev,
pci_set_master(pdev);
ret = of_platform_default_populate(dev_of_node(dev), NULL, dev);
- if (ret)
+ if (ret) {
+ of_platform_depopulate(dev);
goto err_unload_overlay;
+ }
return 0;
--
2.50.1