From patchwork Wed Mar 28 16:22:16 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emil Velikov X-Patchwork-Id: 10313551 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 81608600F6 for ; Wed, 28 Mar 2018 16:28:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 658E028CD4 for ; Wed, 28 Mar 2018 16:28:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5A40428D13; Wed, 28 Mar 2018 16:28:24 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F376528CD4 for ; Wed, 28 Mar 2018 16:28:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753164AbeC1Q2V (ORCPT ); Wed, 28 Mar 2018 12:28:21 -0400 Received: from mail-wr0-f195.google.com ([209.85.128.195]:46780 "EHLO mail-wr0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753227AbeC1Q2T (ORCPT ); Wed, 28 Mar 2018 12:28:19 -0400 Received: by mail-wr0-f195.google.com with SMTP id d1so2811650wrj.13 for ; Wed, 28 Mar 2018 09:28:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Ap5f/A4r9xDvR+HxMWqvNR1AVN2uxCCjlayq3JTRY9Q=; b=r8e95zjt2a6CDsQG/C/C5OTuet29JDQ5h3876OTBl0SH5ZviYzo7kxEfr75qPJpL64 FanC1Z1oHGMvaWz5WvI2zCivt6Irejzj55yoW5TV+45uj+wf3TJ+WVxNnwxOsZ5GBuwx uy0Gl940as1jqw657A6Fqks3h+ZCEd+QfCjK8r5F0hsaeIvnTbqHQnhviFL4KaDuiFhF ZwL9w+Q2J8wSLpZaAxoab4PjhFA16L8c+ulM6Ty791gOEUHlDZYY26MXrWuUlDN2ECTh tEiO3KaES/KjmG5uxRdBiGyfKBNDORfmIqb3VfAHbtqD9mWJ9el3SetrcjAnXogOMFnG AA2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Ap5f/A4r9xDvR+HxMWqvNR1AVN2uxCCjlayq3JTRY9Q=; b=SkT73OdSzAj/4kaf9cy0vmtzdjZIogKbvdHE4Z4BHowApuI8UFRL8APXXByL64qKT+ M1yjltY3oW9l86TPdETYNO0A2LjULbLe9Biv7mnrrDaXTMPOOQ292ARbjfU6xebznOtn aCqBLZcsgLhD64HUYof3UWqS7Y6pfuZB5zGq6+Q4Cr7zMI5QwIDst/LVue/5KlaFqck0 uZWly8+gQ3DGagUk8vulleBiWkOh5w+N27vh85HR/E5Gnx599iUqsVJy3ERXe9JwtGSs 8QRl1NDJMfRm60EGKsdVZeaUTGvLvcKpgl6i6P5L5aCoMOcz3DLW57M+wvZrMu5Sxzyc 7zcA== X-Gm-Message-State: AElRT7GovzVWnp9y0ZrLGLWZ/CVDolGUBoGMseA9u505PKFJVXgKeSPf UegSBuAyOLmAYLoBqtgUYaY= X-Google-Smtp-Source: AIpwx4/D3VTEgghHWHUbkL8bb5JPJZyXSSd5u6NtwegqRWf7MLFFdaPopTZfl+bsZ0k0eGQKkLdMUQ== X-Received: by 10.223.197.196 with SMTP id v4mr3659497wrg.96.1522254497965; Wed, 28 Mar 2018 09:28:17 -0700 (PDT) Received: from arch-x1c3.cbg.collabora.co.uk ([2a00:5f00:102:0:9665:9cff:feee:aa4d]) by smtp.gmail.com with ESMTPSA id l17sm4737946wrh.58.2018.03.28.09.28.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 28 Mar 2018 09:28:17 -0700 (PDT) From: Emil Velikov To: dri-devel@lists.freedesktop.org Cc: emil.l.velikov@gmail.com, Rob Clark , linux-arm-msm@vger.kernel.org, freedreno@lists.freedesktop.org Subject: [PATCH v2] drm/msm: don't deref error pointer in the msm_fbdev_create error path Date: Wed, 28 Mar 2018 17:22:16 +0100 Message-Id: <20180328162216.8595-1-emil.l.velikov@gmail.com> X-Mailer: git-send-email 2.16.0 In-Reply-To: <20180328155347.7472-1-emil.l.velikov@gmail.com> References: <20180328155347.7472-1-emil.l.velikov@gmail.com> Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Emil Velikov Currently the error pointer returned by msm_alloc_stolen_fb gets passed to drm_framebuffer_remove. The latter handles only NULL pointers, thus a nasty crash will occur. Drop the unnecessary fail label and the associated checks - both err and fb will be set at this stage. Cc: Rob Clark Cc: linux-arm-msm@vger.kernel.org Cc: dri-devel@lists.freedesktop.org Cc: freedreno@lists.freedesktop.org Signed-off-by: Emil Velikov --- v2: really remove the fail label :-\ --- drivers/gpu/drm/msm/msm_fbdev.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/drivers/gpu/drm/msm/msm_fbdev.c b/drivers/gpu/drm/msm/msm_fbdev.c index c178563fcd4d..456622b46335 100644 --- a/drivers/gpu/drm/msm/msm_fbdev.c +++ b/drivers/gpu/drm/msm/msm_fbdev.c @@ -92,8 +92,7 @@ static int msm_fbdev_create(struct drm_fb_helper *helper, if (IS_ERR(fb)) { dev_err(dev->dev, "failed to allocate fb\n"); - ret = PTR_ERR(fb); - goto fail; + return PTR_ERR(fb); } bo = msm_framebuffer_bo(fb, 0); @@ -151,13 +150,7 @@ static int msm_fbdev_create(struct drm_fb_helper *helper, fail_unlock: mutex_unlock(&dev->struct_mutex); -fail: - - if (ret) { - if (fb) - drm_framebuffer_remove(fb); - } - + drm_framebuffer_remove(fb); return ret; }