git: 2520675d3f0e - main - superio: Use a bus_child_deleted method to free ivars for children
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Fri, 01 Nov 2024 14:13:05 UTC
The branch main has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=2520675d3f0ef9039049fd67481f013b36f250ee commit 2520675d3f0ef9039049fd67481f013b36f250ee Author: John Baldwin <jhb@FreeBSD.org> AuthorDate: 2024-11-01 14:09:21 +0000 Commit: John Baldwin <jhb@FreeBSD.org> CommitDate: 2024-11-01 14:09:21 +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 --- 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 960b89c0cdc0..7dbd7d30907a 100644 --- a/sys/dev/superio/superio.c +++ b/sys/dev/superio/superio.c @@ -768,6 +768,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) { @@ -1078,6 +1090,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),