git: b669f1b35c79 - stable/13 - isa: Use a bus_child_deleted method to free ivars for children

From: John Baldwin <jhb_at_FreeBSD.org>
Date: Sun, 01 Dec 2024 04:58:02 UTC
The branch stable/13 has been updated by jhb:

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

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

    isa: Use a bus_child_deleted method to free ivars for children
    
    Reviewed by:    imp
    Differential Revision:  https://reviews.freebsd.org/D47368
    
    (cherry picked from commit c8fa54882226d89e987fb26b94979aed85a3bd9a)
---
 sys/isa/isa_common.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/sys/isa/isa_common.c b/sys/isa/isa_common.c
index 856551a7abba..29b48375257c 100644
--- a/sys/isa/isa_common.c
+++ b/sys/isa/isa_common.c
@@ -626,6 +626,12 @@ isa_add_child(device_t dev, u_int order, const char *name, int unit)
 	return (child);
 }
 
+static void
+isa_child_deleted(device_t dev, device_t child)
+{
+	free(device_get_ivars(child), M_ISADEV);
+}
+
 static int
 isa_print_all_resources(device_t dev)
 {
@@ -1068,6 +1074,7 @@ static device_method_t isa_methods[] = {
 
 	/* Bus interface */
 	DEVMETHOD(bus_add_child,	isa_add_child),
+	DEVMETHOD(bus_child_deleted,	isa_child_deleted),
 	DEVMETHOD(bus_print_child,	isa_print_child),
 	DEVMETHOD(bus_probe_nomatch,	isa_probe_nomatch),
 	DEVMETHOD(bus_read_ivar,	isa_read_ivar),