[PATCH] misc: lan966x_pci: depopulate children on populate failure

From: Pengpeng Hou

Date: Mon Jun 15 2026 - 20:52:41 EST


lan966x_pci_probe() loads the device-tree overlay and then populates
child devices from it. If of_platform_default_populate() fails after
creating any children, the error path removes the overlay without first
depopulating the partially-created children.

Mirror the remove path ordering on the populate failure path by
depopulating child devices before unloading the overlay.

Signed-off-by: Pengpeng Hou <pengpeng@xxxxxxxxxxx>
---
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 0bb90c0943bf..823fa06aa1e7 100644
--- a/drivers/misc/lan966x_pci.c
+++ b/drivers/misc/lan966x_pci.c
@@ -178,10 +178,12 @@ static int lan966x_pci_probe(struct pci_dev *pdev, const struct pci_device_id *i

ret = of_platform_default_populate(dev_of_node(dev), NULL, dev);
if (ret)
- goto err_unload_overlay;
+ goto err_depopulate;

return 0;

+err_depopulate:
+ of_platform_depopulate(dev);
err_unload_overlay:
lan966x_pci_unload_overlay(data);
return ret;
--
2.50.1 (Apple Git-155)