git: 925e1016b163 - main - puc: Use device_delete_children if attach fails

From: John Baldwin <jhb_at_FreeBSD.org>
Date: Thu, 02 Jan 2025 18:28:35 UTC
The branch main has been updated by jhb:

URL: https://cgit.FreeBSD.org/src/commit/?id=925e1016b163701268a4298d1eca4b2484a81526

commit 925e1016b163701268a4298d1eca4b2484a81526
Author:     John Baldwin <jhb@FreeBSD.org>
AuthorDate: 2025-01-02 18:25:38 +0000
Commit:     John Baldwin <jhb@FreeBSD.org>
CommitDate: 2025-01-02 18:25:38 +0000

    puc: Use device_delete_children if attach fails
    
    This is slightly simpler than deleting individual devices.
    
    Differential Revision:  https://reviews.freebsd.org/D47974
---
 sys/dev/puc/puc.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/sys/dev/puc/puc.c b/sys/dev/puc/puc.c
index e10d0374c7de..d55fdf63e70b 100644
--- a/sys/dev/puc/puc.c
+++ b/sys/dev/puc/puc.c
@@ -373,10 +373,9 @@ puc_bfe_attach(device_t dev)
 	return (0);
 
 fail:
+	device_delete_children(dev);
 	for (idx = 0; idx < sc->sc_nports; idx++) {
 		port = &sc->sc_port[idx];
-		if (port->p_dev != NULL)
-			device_delete_child(dev, port->p_dev);
 		if (port->p_rres != NULL)
 			rman_release_resource(port->p_rres);
 		if (port->p_ires != NULL)