Blob Blame History Raw
From 789d4c300e10eb2096ee83c3497118e67ccc951e Mon Sep 17 00:00:00 2001
From: Emil Velikov <emil.velikov@collabora.com>
Date: Wed, 28 Mar 2018 17:22:16 +0100
Subject: drm/msm: don't deref error pointer in the msm_fbdev_create error path
References: bsc#1100209
Patch-mainline: v4.17-rc3
Git-commit: 789d4c300e10eb2096ee83c3497118e67ccc951e

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.

Changes during backport:

  * Reduced the upstream patch to returning an error code.  Changes
    to the error recovery have been removed from the patch, as the 
    roll-back code is still required by other parts of the function.

Cc: Rob Clark <robdclark@gmail.com>
Cc: linux-arm-msm@vger.kernel.org
Cc: dri-devel@lists.freedesktop.org
Cc: freedreno@lists.freedesktop.org
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Signed-off-by: Rob Clark <robdclark@gmail.com>
Acked-by: Thomas Zimmermann <tzimmermann@suse.de>

---
 drivers/gpu/drm/msm/msm_fbdev.c |    3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

--- a/drivers/gpu/drm/msm/msm_fbdev.c
+++ b/drivers/gpu/drm/msm/msm_fbdev.c
@@ -113,8 +113,7 @@ static int msm_fbdev_create(struct drm_f
 		 * to unref the bo:
 		 */
 		drm_gem_object_unreference_unlocked(fbdev->bo);
-		ret = PTR_ERR(fb);
-		goto fail;
+		return PTR_ERR(fb);
 	}
 
 	mutex_lock(&dev->struct_mutex);