Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 1 Dec 2024 04:57:59 GMT
From:      John Baldwin <jhb@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: 2e8eefcf3b31 - stable/13 - msk/sk: Use a bus_child_deleted method to free ivars for children
Message-ID:  <202412010457.4B14vxui097552@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/13 has been updated by jhb:

URL: https://cgit.FreeBSD.org/src/commit/?id=2e8eefcf3b3120a014abec6232ee3bb5c05e9bd7

commit 2e8eefcf3b3120a014abec6232ee3bb5c05e9bd7
Author:     John Baldwin <jhb@FreeBSD.org>
AuthorDate: 2024-11-01 14:09:01 +0000
Commit:     John Baldwin <jhb@FreeBSD.org>
CommitDate: 2024-11-30 21:42:09 +0000

    msk/sk: Use a bus_child_deleted method to free ivars for children
    
    Reviewed by:    imp
    Differential Revision:  https://reviews.freebsd.org/D47365
    
    (cherry picked from commit 2ff5c85027356038969d03c2beb55b98db389b41)
---
 sys/dev/msk/if_msk.c | 12 ++++++++----
 sys/dev/sk/if_sk.c   | 10 ++++++++--
 2 files changed, 16 insertions(+), 6 deletions(-)

diff --git a/sys/dev/msk/if_msk.c b/sys/dev/msk/if_msk.c
index dfb1de57e39e..e706387e58d3 100644
--- a/sys/dev/msk/if_msk.c
+++ b/sys/dev/msk/if_msk.c
@@ -253,6 +253,7 @@ static const char *model_name[] = {
 
 static int mskc_probe(device_t);
 static int mskc_attach(device_t);
+static void mskc_child_deleted(device_t, device_t);
 static int mskc_detach(device_t);
 static int mskc_shutdown(device_t);
 static int mskc_setup_rambuffer(struct msk_softc *);
@@ -336,6 +337,7 @@ static device_method_t mskc_methods[] = {
 	DEVMETHOD(device_resume,	mskc_resume),
 	DEVMETHOD(device_shutdown,	mskc_shutdown),
 
+	DEVMETHOD(bus_child_deleted,	mskc_child_deleted),
 	DEVMETHOD(bus_get_dma_tag,	mskc_get_dma_tag),
 
 	DEVMETHOD_END
@@ -2054,6 +2056,12 @@ msk_detach(device_t dev)
 	return (0);
 }
 
+static void
+mskc_child_deleted(device_t dev, device_t child)
+{
+	free(device_get_ivars(child), M_DEVBUF);
+}
+
 static int
 mskc_detach(device_t dev)
 {
@@ -2064,13 +2072,9 @@ mskc_detach(device_t dev)
 
 	if (device_is_alive(dev)) {
 		if (sc->msk_devs[MSK_PORT_A] != NULL) {
-			free(device_get_ivars(sc->msk_devs[MSK_PORT_A]),
-			    M_DEVBUF);
 			device_delete_child(dev, sc->msk_devs[MSK_PORT_A]);
 		}
 		if (sc->msk_devs[MSK_PORT_B] != NULL) {
-			free(device_get_ivars(sc->msk_devs[MSK_PORT_B]),
-			    M_DEVBUF);
 			device_delete_child(dev, sc->msk_devs[MSK_PORT_B]);
 		}
 		bus_generic_detach(dev);
diff --git a/sys/dev/sk/if_sk.c b/sys/dev/sk/if_sk.c
index 484954bd9bad..1688d590c149 100644
--- a/sys/dev/sk/if_sk.c
+++ b/sys/dev/sk/if_sk.c
@@ -185,6 +185,7 @@ static const struct sk_type sk_devs[] = {
 
 static int skc_probe(device_t);
 static int skc_attach(device_t);
+static void skc_child_deleted(device_t, device_t);
 static int skc_detach(device_t);
 static int skc_shutdown(device_t);
 static int skc_suspend(device_t);
@@ -291,6 +292,7 @@ static device_method_t skc_methods[] = {
 	DEVMETHOD(device_resume,	skc_resume),
 	DEVMETHOD(device_shutdown,	skc_shutdown),
 
+	DEVMETHOD(bus_child_deleted,	skc_child_deleted),
 	DEVMETHOD(bus_get_dma_tag,	skc_get_dma_tag),
 
 	DEVMETHOD_END
@@ -1743,6 +1745,12 @@ fail:
 	return(error);
 }
 
+static void
+skc_child_deleted(device_t dev, device_t child)
+{
+	free(device_get_ivars(child), M_DEVBUF);
+}
+
 /*
  * Shutdown hardware and free up resources. This can be called any
  * time after the mutex has been initialized. It is called in both
@@ -1801,11 +1809,9 @@ skc_detach(device_t dev)
 
 	if (device_is_alive(dev)) {
 		if (sc->sk_devs[SK_PORT_A] != NULL) {
-			free(device_get_ivars(sc->sk_devs[SK_PORT_A]), M_DEVBUF);
 			device_delete_child(dev, sc->sk_devs[SK_PORT_A]);
 		}
 		if (sc->sk_devs[SK_PORT_B] != NULL) {
-			free(device_get_ivars(sc->sk_devs[SK_PORT_B]), M_DEVBUF);
 			device_delete_child(dev, sc->sk_devs[SK_PORT_B]);
 		}
 		bus_generic_detach(dev);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202412010457.4B14vxui097552>