From patchwork Thu Dec 5 00:19:40 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Ilia Mirkin X-Patchwork-Id: 3285901 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id B728A9F37C for ; Thu, 5 Dec 2013 00:20:08 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C9298204E2 for ; Thu, 5 Dec 2013 00:20:07 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id D468E20498 for ; Thu, 5 Dec 2013 00:20:06 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A00EFFB8DD for ; Wed, 4 Dec 2013 16:20:06 -0800 (PST) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-qc0-f169.google.com (mail-qc0-f169.google.com [209.85.216.169]) by gabe.freedesktop.org (Postfix) with ESMTP id D1054FAB7B for ; Wed, 4 Dec 2013 16:19:53 -0800 (PST) Received: by mail-qc0-f169.google.com with SMTP id r5so4184567qcx.14 for ; Wed, 04 Dec 2013 16:19:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-type:content-transfer-encoding; bh=DkZaueBCo94qyhZ81oPLFckjh6v5r3HhP+OKkHctOKc=; b=Yp5GJtyy61WRbmcsU6DLksz7zsr5su/Eu2ADLwLAYT5Pj78PPFpJB4sPg3ij/kBY6J GRDekfzlxDFpi6SDW8RGq7VQNjWkPWfgb+REPEmkWmjawJwdLyardMpOz8Lw62I6Ww+a zH/4IJG5b3lKA2w5oNIdCKd9CJizhXYQcqzUvYmii3WPhbCry5QMbeP/Z3OckXOvjPyz iMaz3wpB85tMPxbgS67mergXWfYnjg/qhIkji99J2pL9GNb+HiJ1FU2VendUKT3t1cUS g1uPmYHrcoOKLRC2P1XY+GVQue2WlUul6i78LLqMyXsJC/NSWgtYMSFbrerGDa0jCXJX DYTQ== X-Received: by 10.224.11.7 with SMTP id r7mr100080771qar.91.1386202793423; Wed, 04 Dec 2013 16:19:53 -0800 (PST) Received: from aramis.hellosponsor.com (216.156.99.94.ptr.us.xo.net. [216.156.99.94]) by mx.google.com with ESMTPSA id hb2sm23010381qeb.6.2013.12.04.16.19.52 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 04 Dec 2013 16:19:52 -0800 (PST) From: Ilia Mirkin To: Dave Airlie Subject: [PATCH] drm: don't double-free on driver load error Date: Wed, 4 Dec 2013 19:19:40 -0500 Message-Id: <1386202780-25731-1-git-send-email-imirkin@alum.mit.edu> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: References: MIME-Version: 1.0 Cc: Bruno Premont , dri-devel@lists.freedesktop.org X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: dri-devel-bounces+patchwork-dri-devel=patchwork.kernel.org@lists.freedesktop.org Errors-To: dri-devel-bounces+patchwork-dri-devel=patchwork.kernel.org@lists.freedesktop.org X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP All instances of drm_dev_register are followed by drm_dev_free on failure. Don't free dev->control/render/primary on failure, as they will be freed by drm_dev_free since commit 8f6599da8e (drm: delay minor destruction to drm_dev_free()). Reported-by: Bruno Prémont Signed-off-by: Ilia Mirkin --- Bruno, would be nice if you could test this out on your setup without the patch that makes load succeed. Ideally this will make drm not die in the case that nouveau load fails. drivers/gpu/drm/drm_stub.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/drivers/gpu/drm/drm_stub.c b/drivers/gpu/drm/drm_stub.c index f53d524..cd427b8 100644 --- a/drivers/gpu/drm/drm_stub.c +++ b/drivers/gpu/drm/drm_stub.c @@ -536,17 +536,17 @@ int drm_dev_register(struct drm_device *dev, unsigned long flags) if (drm_core_check_feature(dev, DRIVER_RENDER) && drm_rnodes) { ret = drm_get_minor(dev, &dev->render, DRM_MINOR_RENDER); if (ret) - goto err_control_node; + goto err_agp; } ret = drm_get_minor(dev, &dev->primary, DRM_MINOR_LEGACY); if (ret) - goto err_render_node; + goto err_agp; if (dev->driver->load) { ret = dev->driver->load(dev, flags); if (ret) - goto err_primary_node; + goto err_agp; } /* setup grouping for legacy outputs */ @@ -565,12 +565,6 @@ int drm_dev_register(struct drm_device *dev, unsigned long flags) err_unload: if (dev->driver->unload) dev->driver->unload(dev); -err_primary_node: - drm_put_minor(dev->primary); -err_render_node: - drm_put_minor(dev->render); -err_control_node: - drm_put_minor(dev->control); err_agp: if (dev->driver->bus->agp_destroy) dev->driver->bus->agp_destroy(dev);