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: 10313533 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 7846060212 for ; Wed, 28 Mar 2018 15:59:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 683E928FCD for ; Wed, 28 Mar 2018 15:59:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5BB222980A; Wed, 28 Mar 2018 15:59:55 +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 F006728FCD for ; Wed, 28 Mar 2018 15:59:53 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 2E4B56E371; Wed, 28 Mar 2018 15:59:51 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wr0-x241.google.com (mail-wr0-x241.google.com [IPv6:2a00:1450:400c:c0c::241]) by gabe.freedesktop.org (Postfix) with ESMTPS id D0EA46E38A; Wed, 28 Mar 2018 15:59:49 +0000 (UTC) Received: by mail-wr0-x241.google.com with SMTP id z73so2742592wrb.0; Wed, 28 Mar 2018 08:59:49 -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=YOhPG8PTMlDPA7+wBD7XbYEry23nlOthTluV+y+VGC7Z3dPI9aP51+B89O4rReYKwW f90z3SXefhNOcvR00SEg0j5H19XFTA5Zw6BsVJxoeIsU9N2OoOsk8sTgNX/CiMxEb9uZ 32RnSv1SD9OAPlt21gfJvru9J8lhm5cBTqpZhc+xzB9c8vJmBKXzfd9VKMsj7HCsX99x WkvD4DftL1gl2ItWZXE+mAkmet9YRetC38MCXN+tSsTpDsDi1kiY/mt3pleexlvaZt6l WpT8co1cgu5tmkZz+Pz7qGWynepriEDVxH05triyExSHfm0+7Un9OXfZ8+X3MXO2mbN6 dALw== X-Gm-Message-State: AElRT7Gwe6Hgfz/0d/QQui6sBEjcyARYgn1EC5qmGb9tU4dUDDkOV94m k/peLji5G0Z8QAcqpGUqJNjMUw== 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 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 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 --- 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; }