From patchwork Fri Mar 18 09:02:19 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Carpenter X-Patchwork-Id: 8617271 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.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 1C5ED9F44D for ; Fri, 18 Mar 2016 09:02:51 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8CF1520374 for ; Fri, 18 Mar 2016 09:02:45 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id DC786202F0 for ; Fri, 18 Mar 2016 09:02:43 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 72C496EB83; Fri, 18 Mar 2016 09:02:41 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from aserp1040.oracle.com (aserp1040.oracle.com [141.146.126.69]) by gabe.freedesktop.org (Postfix) with ESMTPS id 2F1EE6EB83 for ; Fri, 18 Mar 2016 09:02:39 +0000 (UTC) Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by aserp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id u2I92UkL021359 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 18 Mar 2016 09:02:30 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserv0021.oracle.com (8.13.8/8.13.8) with ESMTP id u2I92TVa001529 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL); Fri, 18 Mar 2016 09:02:30 GMT Received: from abhmp0004.oracle.com (abhmp0004.oracle.com [141.146.116.10]) by userv0121.oracle.com (8.13.8/8.13.8) with ESMTP id u2I92RcA019525; Fri, 18 Mar 2016 09:02:27 GMT Received: from mwanda (/154.0.139.178) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 18 Mar 2016 02:02:26 -0700 Date: Fri, 18 Mar 2016 12:02:19 +0300 From: Dan Carpenter To: Thierry Reding Subject: [patch] drm/tegra: fixup error handling in tegra_dc_init() Message-ID: <20160318090219.GB19233@mwanda> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.24 (2015-08-30) X-Source-IP: aserv0021.oracle.com [141.146.126.233] Cc: Alexandre Courbot , Terje =?iso-8859-1?Q?Bergstr=F6m?= , Stephen Warren , kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-tegra@vger.kernel.org X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, 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 1) There was a chance that "cursor" or "primary" were error pointers leading to an oops. 2) The error handling wasn't very complete. When I started working on this, the one err label style error handling became unwieldy so I just re-wrote it with multiple exit labels. Signed-off-by: Dan Carpenter --- Compile tested only. diff --git a/drivers/gpu/drm/tegra/dc.c b/drivers/gpu/drm/tegra/dc.c index fb2b4b0..8134e30 100644 --- a/drivers/gpu/drm/tegra/dc.c +++ b/drivers/gpu/drm/tegra/dc.c @@ -1683,8 +1683,8 @@ static int tegra_dc_init(struct host1x_client *client) unsigned long flags = HOST1X_SYNCPT_CLIENT_MANAGED; struct tegra_dc *dc = host1x_client_to_dc(client); struct tegra_drm *tegra = drm->dev_private; - struct drm_plane *primary = NULL; - struct drm_plane *cursor = NULL; + struct drm_plane *primary; + struct drm_plane *cursor; u32 value; int err; @@ -1706,21 +1706,22 @@ static int tegra_dc_init(struct host1x_client *client) primary = tegra_dc_primary_plane_create(drm, dc); if (IS_ERR(primary)) { err = PTR_ERR(primary); - goto cleanup; + goto detach_iommu; } + cursor = NULL; if (dc->soc->supports_cursor) { cursor = tegra_dc_cursor_plane_create(drm, dc); if (IS_ERR(cursor)) { err = PTR_ERR(cursor); - goto cleanup; + goto cleanup_primary; } } err = drm_crtc_init_with_planes(drm, &dc->base, primary, cursor, &tegra_crtc_funcs, NULL); if (err < 0) - goto cleanup; + goto cleanup_cursor; drm_mode_crtc_set_gamma_size(&dc->base, 256); drm_crtc_helper_add(&dc->base, &tegra_crtc_helper_funcs); @@ -1735,12 +1736,12 @@ static int tegra_dc_init(struct host1x_client *client) err = tegra_dc_rgb_init(drm, dc); if (err < 0 && err != -ENODEV) { dev_err(dc->dev, "failed to initialize RGB output: %d\n", err); - goto cleanup; + goto cleanup_cursor; } err = tegra_dc_add_planes(drm, dc); if (err < 0) - goto cleanup; + goto rgb_exit; if (IS_ENABLED(CONFIG_DEBUG_FS)) { err = tegra_dc_debugfs_init(dc, drm->primary); @@ -1753,7 +1754,7 @@ static int tegra_dc_init(struct host1x_client *client) if (err < 0) { dev_err(dc->dev, "failed to request IRQ#%u: %d\n", dc->irq, err); - goto cleanup; + goto remove_debugfs; } /* initialize display controller */ @@ -1799,13 +1800,18 @@ static int tegra_dc_init(struct host1x_client *client) return 0; -cleanup: - if (cursor) +remove_debugfs: + tegra_dc_debugfs_exit(dc); +rgb_exit: + tegra_dc_rgb_exit(dc); +cleanup_cursor: + if (dc->soc->supports_cursor) drm_plane_cleanup(cursor); - if (primary) - drm_plane_cleanup(primary); +cleanup_primary: + drm_plane_cleanup(primary); +detach_iommu: if (tegra->domain) { iommu_detach_device(tegra->domain, dc->dev); dc->domain = NULL;