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: 10313549 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 90785600F6 for ; Wed, 28 Mar 2018 16:28:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7F7CF28CFB for ; Wed, 28 Mar 2018 16:28:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7250E28CD4; Wed, 28 Mar 2018 16:28:23 +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=-4.1 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 12EA528CD4 for ; Wed, 28 Mar 2018 16:28:23 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 1F2ED6E47D; Wed, 28 Mar 2018 16:28:21 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wr0-x244.google.com (mail-wr0-x244.google.com [IPv6:2a00:1450:400c:c0c::244]) by gabe.freedesktop.org (Postfix) with ESMTPS id 731AB6E5E8; Wed, 28 Mar 2018 16:28:19 +0000 (UTC) Received: by mail-wr0-x244.google.com with SMTP id u11so2805624wri.12; Wed, 28 Mar 2018 09:28:19 -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=JKgBqfAlp5Kb5jBbVNUv98uDKJqTzrbNnnP8jhc1WbnpiU4EbHM3dZI+JRzOA5GOVR xogEKUmcxRW28FsLpvQhC4Hzy5XUxlnlMYqiLj5vpG6sYQWrxlaBVXFqyPahCpBZmsGE DBcn9V0Cr+vFbKSZZumNynNEItyCYvQ7/M1kkv4BxNvr558U1OW4ig4fAhC4XkFpDyJ4 pwLBK7kYiEe4u30OELh8ZfugyAwlX9I82sAJXKZ2Y3v2WH3MuJ76ybP1Qt5nusVDO4+P cpsyhSAH9BrFdC8/QjWav1kxU+YFSExgKrRC4XJlcFGGFwp7+h+Mn8me5jUGl7fPswjj Xc4w== X-Gm-Message-State: AElRT7Ge0JUdd1+Y+NGquUgQc0IhUkRn75AwY1RbxLBF/yxa1c7kmOn1 SnQhq0bKoHMBEdscfgsc3+mB6w== 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 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> X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-arm-msm@vger.kernel.org, freedreno@lists.freedesktop.org, emil.l.velikov@gmail.com MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" 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; }