summaryrefslogtreecommitdiffstats
path: root/sys/dev/ahci/ahci.c
diff options
context:
space:
mode:
authormav <mav@FreeBSD.org>2010-06-05 08:02:19 +0000
committermav <mav@FreeBSD.org>2010-06-05 08:02:19 +0000
commitd49dd001960ee7b7c1ba09fc1237731abaf07fdf (patch)
treeb21a5dcd9f9b73c8a5c004aad6258c9d05f7583d /sys/dev/ahci/ahci.c
parentb0cd47b6029de92b06b4f70ec78b0e05f4ea7b8e (diff)
downloadFreeBSD-src-d49dd001960ee7b7c1ba09fc1237731abaf07fdf.zip
FreeBSD-src-d49dd001960ee7b7c1ba09fc1237731abaf07fdf.tar.gz
Fix attach errors handling.
Found with: Coverity Prevent(tm) CID: 3424
Diffstat (limited to 'sys/dev/ahci/ahci.c')
-rw-r--r--sys/dev/ahci/ahci.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/sys/dev/ahci/ahci.c b/sys/dev/ahci/ahci.c
index ca86074..ab782eb 100644
--- a/sys/dev/ahci/ahci.c
+++ b/sys/dev/ahci/ahci.c
@@ -898,9 +898,9 @@ ahci_ch_attach(device_t dev)
rid = ATA_IRQ_RID;
if (!(ch->r_irq = bus_alloc_resource_any(dev, SYS_RES_IRQ,
&rid, RF_SHAREABLE | RF_ACTIVE))) {
- bus_release_resource(dev, SYS_RES_MEMORY, ch->unit, ch->r_mem);
device_printf(dev, "Unable to map interrupt\n");
- return (ENXIO);
+ error = ENXIO;
+ goto err0;
}
if ((bus_setup_intr(dev, ch->r_irq, ATA_INTR_FLAGS, NULL,
ahci_ch_intr_locked, dev, &ch->ih))) {
@@ -934,9 +934,10 @@ ahci_ch_attach(device_t dev)
(ch->caps & AHCI_CAP_SNCQ) ? ch->numslots : 0,
devq);
if (ch->sim == NULL) {
+ cam_simq_free(devq);
device_printf(dev, "unable to allocate sim\n");
error = ENOMEM;
- goto err2;
+ goto err1;
}
if (xpt_bus_register(ch->sim, dev, 0) != CAM_SUCCESS) {
device_printf(dev, "unable to register xpt bus\n");
@@ -963,6 +964,7 @@ err2:
cam_sim_free(ch->sim, /*free_devq*/TRUE);
err1:
bus_release_resource(dev, SYS_RES_IRQ, ATA_IRQ_RID, ch->r_irq);
+err0:
bus_release_resource(dev, SYS_RES_MEMORY, ch->unit, ch->r_mem);
mtx_unlock(&ch->mtx);
return (error);
OpenPOWER on IntegriCloud