From owner-svn-src-head@FreeBSD.ORG Sat Nov 22 15:35:22 2008 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 5E67F106564A; Sat, 22 Nov 2008 15:35:22 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 448308FC14; Sat, 22 Nov 2008 15:35:22 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id mAMFZL5X021569; Sat, 22 Nov 2008 15:35:21 GMT (envelope-from mav@svn.freebsd.org) Received: (from mav@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id mAMFZLcZ021568; Sat, 22 Nov 2008 15:35:21 GMT (envelope-from mav@svn.freebsd.org) Message-Id: <200811221535.mAMFZLcZ021568@svn.freebsd.org> From: Alexander Motin Date: Sat, 22 Nov 2008 15:35:21 +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: r185177 - head/sys/dev/sound/pci/hda 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, 22 Nov 2008 15:35:22 -0000 Author: mav Date: Sat Nov 22 15:35:21 2008 New Revision: 185177 URL: http://svn.freebsd.org/changeset/base/185177 Log: Handle device_get_children() errors in more correct way. We shouldn't detach until all children are surely destroyed. Found with: Coverity Prevent(tm) CID: 2137 Modified: head/sys/dev/sound/pci/hda/hdac.c Modified: head/sys/dev/sound/pci/hda/hdac.c ============================================================================== --- head/sys/dev/sound/pci/hda/hdac.c Sat Nov 22 14:48:40 2008 (r185176) +++ head/sys/dev/sound/pci/hda/hdac.c Sat Nov 22 15:35:21 2008 (r185177) @@ -7571,17 +7571,20 @@ static int hdac_detach(device_t dev) { struct hdac_softc *sc; - device_t *devlist = NULL; - int i, devcount; + device_t *devlist; + int i, devcount, error; - sc = device_get_softc(dev); - - device_get_children(dev, &devlist, &devcount); - for (i = 0; devlist != NULL && i < devcount; i++) - device_delete_child(dev, devlist[i]); - if (devlist != NULL) - free(devlist, M_TEMP); + if ((error = device_get_children(dev, &devlist, &devcount)) != 0) + return (error); + for (i = 0; i < devcount; i++) { + if ((error = device_delete_child(dev, devlist[i])) != 0) { + free(devlist, M_TEMP); + return (error); + } + } + free(devlist, M_TEMP); + sc = device_get_softc(dev); hdac_release_resources(sc); return (0);