git: 5c7af84925aa - main - nvdimm: 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:00 UTC
The branch main has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=5c7af84925aa0916983551b0d470b461a70c0f1f commit 5c7af84925aa0916983551b0d470b461a70c0f1f Author: John Baldwin <jhb@FreeBSD.org> AuthorDate: 2024-11-01 14:08:44 +0000 Commit: John Baldwin <jhb@FreeBSD.org> CommitDate: 2024-11-01 14:08:44 +0000 nvdimm: Use a bus_child_deleted method to free ivars for children Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D47363 --- sys/dev/nvdimm/nvdimm_acpi.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/sys/dev/nvdimm/nvdimm_acpi.c b/sys/dev/nvdimm/nvdimm_acpi.c index a8e5db0542f2..f6a7ebe6e2b9 100644 --- a/sys/dev/nvdimm/nvdimm_acpi.c +++ b/sys/dev/nvdimm/nvdimm_acpi.c @@ -197,13 +197,18 @@ nvdimm_root_attach(device_t dev) return (error); } +static void +nvdimm_root_child_deleted(device_t dev, device_t child) +{ + free(device_get_ivars(child), M_NVDIMM_ACPI); +} + static int nvdimm_root_detach(device_t dev) { struct nvdimm_root_dev *root; struct SPA_mapping *spa, *next; - device_t *children; - int i, error, num_children; + int error; root = device_get_softc(dev); SLIST_FOREACH_SAFE(spa, &root->spas, link, next) { @@ -215,12 +220,6 @@ nvdimm_root_detach(device_t dev) error = bus_generic_detach(dev); if (error != 0) return (error); - error = device_get_children(dev, &children, &num_children); - if (error != 0) - return (error); - for (i = 0; i < num_children; i++) - free(device_get_ivars(children[i]), M_NVDIMM_ACPI); - free(children, M_TEMP); error = device_delete_children(dev); return (error); } @@ -264,6 +263,7 @@ static device_method_t nvdimm_acpi_methods[] = { DEVMETHOD(device_attach, nvdimm_root_attach), DEVMETHOD(device_detach, nvdimm_root_detach), DEVMETHOD(bus_add_child, bus_generic_add_child), + DEVMETHOD(bus_child_deleted, nvdimm_root_child_deleted), DEVMETHOD(bus_read_ivar, nvdimm_root_read_ivar), DEVMETHOD(bus_write_ivar, nvdimm_root_write_ivar), DEVMETHOD(bus_child_location, nvdimm_root_child_location),