From owner-svn-src-head@FreeBSD.ORG Sun Aug 25 00:22:35 2013 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 2D1AF991; Sun, 25 Aug 2013 00:22:35 +0000 (UTC) (envelope-from dumbbell@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 1AA9B2CA5; Sun, 25 Aug 2013 00:22:35 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r7P0MY83076717; Sun, 25 Aug 2013 00:22:34 GMT (envelope-from dumbbell@svn.freebsd.org) Received: (from dumbbell@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r7P0MYEN076715; Sun, 25 Aug 2013 00:22:34 GMT (envelope-from dumbbell@svn.freebsd.org) Message-Id: <201308250022.r7P0MYEN076715@svn.freebsd.org> From: Jean-Sebastien Pedron Date: Sun, 25 Aug 2013 00:22:34 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r254821 - head/sys/dev/drm2 X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.14 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: Sun, 25 Aug 2013 00:22:35 -0000 Author: dumbbell Date: Sun Aug 25 00:22:34 2013 New Revision: 254821 URL: http://svnweb.freebsd.org/changeset/base/254821 Log: drm: Fix cleanup if device initialization fails This plugs some memory leaks. Modified: head/sys/dev/drm2/drm_drv.c Modified: head/sys/dev/drm2/drm_drv.c ============================================================================== --- head/sys/dev/drm2/drm_drv.c Sun Aug 25 00:13:53 2013 (r254820) +++ head/sys/dev/drm2/drm_drv.c Sun Aug 25 00:22:34 2013 (r254821) @@ -313,8 +313,22 @@ int drm_attach(device_t kdev, drm_pci_id sx_init(&dev->dev_struct_lock, "drmslk"); error = drm_load(dev); - if (error == 0) - error = drm_create_cdevs(kdev); + if (error) + goto error; + + error = drm_create_cdevs(kdev); + if (error) + goto error; + + return (error); +error: + if (dev->irqr) { + bus_release_resource(dev->device, SYS_RES_IRQ, + dev->irqrid, dev->irqr); + } + if (dev->msi_enabled) { + pci_release_msi(dev->device); + } return (error); } @@ -572,7 +586,7 @@ static int drm_load(struct drm_device *d DRM_ERROR("Request to enable bus-master failed.\n"); DRM_UNLOCK(dev); if (retcode != 0) - goto error; + goto error1; } DRM_INFO("Initialized %s %d.%d.%d %s\n", @@ -586,7 +600,9 @@ static int drm_load(struct drm_device *d error1: delete_unrhdr(dev->drw_unrhdr); + drm_gem_destroy(dev); error: + drm_ctxbitmap_cleanup(dev); drm_sysctl_cleanup(dev); DRM_LOCK(dev); drm_lastclose(dev);