diff --git a/sys/dev/agp/agp.c b/sys/dev/agp/agp.c index d074f1801328..b44cfc94a31b 100644 --- a/sys/dev/agp/agp.c +++ b/sys/dev/agp/agp.c @@ -253,9 +253,10 @@ int agp_generic_detach(device_t dev) { struct agp_softc *sc = device_get_softc(dev); + + destroy_dev(sc->as_devnode); bus_release_resource(dev, SYS_RES_MEMORY, AGP_APBASE, sc->as_aperture); mtx_destroy(&sc->as_lock); - destroy_dev(sc->as_devnode); agp_flush_cache(); return 0; } diff --git a/sys/pci/agp.c b/sys/pci/agp.c index d074f1801328..b44cfc94a31b 100644 --- a/sys/pci/agp.c +++ b/sys/pci/agp.c @@ -253,9 +253,10 @@ int agp_generic_detach(device_t dev) { struct agp_softc *sc = device_get_softc(dev); + + destroy_dev(sc->as_devnode); bus_release_resource(dev, SYS_RES_MEMORY, AGP_APBASE, sc->as_aperture); mtx_destroy(&sc->as_lock); - destroy_dev(sc->as_devnode); agp_flush_cache(); return 0; }