From owner-svn-src-head@FreeBSD.ORG Sat Jun 5 08:02:19 2010 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A0DBA106566C; Sat, 5 Jun 2010 08:02:19 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from svn.freebsd.org (unknown [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 90B6B8FC16; Sat, 5 Jun 2010 08:02:19 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o5582JlS058366; Sat, 5 Jun 2010 08:02:19 GMT (envelope-from mav@svn.freebsd.org) Received: (from mav@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o5582JuT058363; Sat, 5 Jun 2010 08:02:19 GMT (envelope-from mav@svn.freebsd.org) Message-Id: <201006050802.o5582JuT058363@svn.freebsd.org> From: Alexander Motin Date: Sat, 5 Jun 2010 08:02:19 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r208813 - head/sys/dev/ahci X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 05 Jun 2010 08:02:19 -0000 Author: mav Date: Sat Jun 5 08:02:19 2010 New Revision: 208813 URL: http://svn.freebsd.org/changeset/base/208813 Log: Fix attach errors handling. Found with: Coverity Prevent(tm) CID: 3424 Modified: head/sys/dev/ahci/ahci.c Modified: head/sys/dev/ahci/ahci.c ============================================================================== --- head/sys/dev/ahci/ahci.c Sat Jun 5 08:00:52 2010 (r208812) +++ head/sys/dev/ahci/ahci.c Sat Jun 5 08:02:19 2010 (r208813) @@ -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);