From patchwork Wed Mar 28 15:53:47 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emil Velikov X-Patchwork-Id: 10313535 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 5A46B60212 for ; Wed, 28 Mar 2018 15:59:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4AB1228FCD for ; Wed, 28 Mar 2018 15:59:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3E6C428FD1; Wed, 28 Mar 2018 15:59:56 +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 5AA3F28FCF for ; Wed, 28 Mar 2018 15:59:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754093AbeC1P7w (ORCPT ); Wed, 28 Mar 2018 11:59:52 -0400 Received: from mail-wr0-f196.google.com ([209.85.128.196]:39075 "EHLO mail-wr0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753816AbeC1P7t (ORCPT ); Wed, 28 Mar 2018 11:59:49 -0400 Received: by mail-wr0-f196.google.com with SMTP id c24so2736613wrc.6 for ; Wed, 28 Mar 2018 08:59:48 -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; bh=ZFkIKkMibwZ5R281Raccs0niwQ/8Qxr53h76ai6Ebq4=; b=LONzusTHzkJUMNzo93Qv3OBCtB6vMS7HfMHVMmHwhpTqIqW15iR0qbAYEc8+kkCjlw Y7FuG+DDIjsi9nH6u/VtOGbpa8U/5MB66tTLfCcoQyE8AKTcyIVoyonki4rNX21EKgj0 xLHbN0oHmvQwvUF6f+GZZds3R1fcuV2q7HB7dzQtBXmjUlv7CSqsXVYmW/VSVoSYh52j MoPcWsrbBffUSQdoseVm9dBAdhHYSJFGQaq0bltCu0+mJetP7agC4o2gOjD5KWXuj+TU ZcdXGE+o4AS8bImvDklaOSKxNwX5tkErlygh5mLGT+QlD+yLkw6LVh25ev4WJjoYJddS OlxA== 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; bh=ZFkIKkMibwZ5R281Raccs0niwQ/8Qxr53h76ai6Ebq4=; b=SmALZ9ffnyufvyHLGYY13exsmyi3J6taXCiag/glMH+TnPDXETVIDodwndxxgsOCEK E5h4/H+qEUwOx6rZes9Sk9i3l4fk/uDe2kpyNnLTBRY88OoN971ScLtKF2behj5KVJQ3 Yjqd9e+9Z41eAkbQvQ+oXmZQ/osyBtRtE7YkhAlWklFY5y0Mf2ElGEzpKCFtLTf1bkMH dQnDZkFBu2RhQbdUAs7LPJ9wDxBCD9oXv11vD8htRGtWrHzeZvAG2s+Firtj8YGFyv7w RJRfh6kXPwWs6ETGzcfwh5hGEyCWh6jKiSkg2YjR5Hih+i0LtMWGyfdyaV5gK0agH0v5 GXQQ== X-Gm-Message-State: AElRT7FfOsXIdNC2A1hn3UbeQHOA9ZLtuYoZvcsU6QagEtejNaq8+rbN M51+jf93movVj8rFnOFpANHE4Q== X-Google-Smtp-Source: AIpwx4+Adfj8AZeCvKHH7eSAuhUlyh237ByzRuXCg8f7+IeLFdEserxkam1MuK8oDD3zCnRe7IXiHw== X-Received: by 10.223.208.202 with SMTP id z10mr3743881wrh.15.1522252788167; Wed, 28 Mar 2018 08:59:48 -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 j126sm3451578wmb.33.2018.03.28.08.59.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 28 Mar 2018 08:59:47 -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] drm/msm: don't deref error pointer in the msm_fbdev_create error path Date: Wed, 28 Mar 2018 16:53:47 +0100 Message-Id: <20180328155347.7472-1-emil.l.velikov@gmail.com> X-Mailer: git-send-email 2.16.0 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 --- drivers/gpu/drm/msm/msm_fbdev.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/drivers/gpu/drm/msm/msm_fbdev.c b/drivers/gpu/drm/msm/msm_fbdev.c index c178563fcd4d..6ed89bcfedf5 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); @@ -153,11 +152,7 @@ static int msm_fbdev_create(struct drm_fb_helper *helper, mutex_unlock(&dev->struct_mutex); fail: - if (ret) { - if (fb) - drm_framebuffer_remove(fb); - } - + drm_framebuffer_remove(fb); return ret; }