Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 1 Dec 2024 04:58:01 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: 8973edf29b3d - stable/13 - superio: Use a bus_child_deleted method to free ivars for children
Message-ID:  <202412010458.4B14w190097615@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=8973edf29b3dffb31b0b481ad462121e50cd3c67

commit 8973edf29b3dffb31b0b481ad462121e50cd3c67
Author:     John Baldwin <jhb@FreeBSD.org>
AuthorDate: 2024-11-01 14:09:21 +0000
Commit:     John Baldwin <jhb@FreeBSD.org>
CommitDate: 2024-11-30 21:43:37 +0000

    superio: Use a bus_child_deleted method to free ivars for children
    
    Previously these ivars were leaked.
    
    Reviewed by:    imp
    Differential Revision:  https://reviews.freebsd.org/D47367
    
    (cherry picked from commit 2520675d3f0ef9039049fd67481f013b36f250ee)
---
 sys/dev/superio/superio.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/sys/dev/superio/superio.c b/sys/dev/superio/superio.c
index dd25a7176d5f..3ad06e04d5cf 100644
--- a/sys/dev/superio/superio.c
+++ b/sys/dev/superio/superio.c
@@ -710,6 +710,18 @@ superio_add_child(device_t dev, u_int order, const char *name, int unit)
 	return (child);
 }
 
+static void
+superio_child_deleted(device_t dev, device_t child)
+{
+	struct superio_devinfo *dinfo;
+
+	dinfo = device_get_ivars(child);
+	if (dinfo == NULL)
+		return;
+	resource_list_free(&dinfo->resources);
+	free(dinfo, M_DEVBUF);
+}
+
 static int
 superio_read_ivar(device_t dev, device_t child, int which, uintptr_t *result)
 {
@@ -1001,6 +1013,7 @@ static device_method_t superio_methods[] = {
 	DEVMETHOD(device_resume,	bus_generic_resume),
 
 	DEVMETHOD(bus_add_child,	superio_add_child),
+	DEVMETHOD(bus_child_deleted,	superio_child_deleted),
 	DEVMETHOD(bus_child_detached,	superio_child_detached),
 	DEVMETHOD(bus_child_location_str, superio_child_location_str),
 	DEVMETHOD(bus_child_pnpinfo_str, superio_child_pnp_str),



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