Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 1 Dec 2024 04:57:12 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: bfe10b7712a5 - stable/14 - superio: Use a bus_child_deleted method to free ivars for children
Message-ID:  <202412010457.4B14vCfF095241@gitrepo.freebsd.org>

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

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

commit bfe10b7712a5c3ab7511f0714c82fb6a022c2450
Author:     John Baldwin <jhb@FreeBSD.org>
AuthorDate: 2024-11-01 14:09:21 +0000
Commit:     John Baldwin <jhb@FreeBSD.org>
CommitDate: 2024-12-01 02:46:06 +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 ff05d378ce92..b8797d1bab0e 100644
--- a/sys/dev/superio/superio.c
+++ b/sys/dev/superio/superio.c
@@ -769,6 +769,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)
 {
@@ -1079,6 +1091,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,	superio_child_location),
 	DEVMETHOD(bus_child_pnpinfo,	superio_child_pnp),



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