From fb805ea785ddb712bcce2a6b2ae91ece90a3ecfa Mon Sep 17 00:00:00 2001 From: Scott Mitchell Date: Mon, 6 Dec 2004 23:17:04 +0000 Subject: [PATCH] Properly release allocated resources if adw(4) device fails to fully attach, eg. if the firmware load fails. Shortish MFC timeout so this can be merged before the 4.11 freeze. PR: kern/34306 Submitted by: gibbs Approved by: gibbs, imp (mentor) MFC after: 5 days --- sys/dev/advansys/adwcam.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/sys/dev/advansys/adwcam.c b/sys/dev/advansys/adwcam.c index f4e7f4cfe91f..400c0fca5271 100644 --- a/sys/dev/advansys/adwcam.c +++ b/sys/dev/advansys/adwcam.c @@ -872,6 +872,26 @@ adw_free(struct adw_softc *adw) case 0: break; } + + if (adw->regs != NULL) + bus_release_resource(adw->device, + adw->regs_res_type, + adw->regs_res_id, + adw->regs); + + if (adw->irq != NULL) + bus_release_resource(adw->device, + adw->irq_res_type, + 0, adw->irq); + + if (adw->sim != NULL) { + if (adw->path != NULL) { + xpt_async(AC_LOST_DEVICE, adw->path, NULL); + xpt_free_path(adw->path); + } + xpt_bus_deregister(cam_sim_path(adw->sim)); + cam_sim_free(adw->sim, /*free_devq*/TRUE); + } free(adw->name, M_DEVBUF); free(adw, M_DEVBUF); }