Skip to content

Commit

Permalink
drm/msm: don't deref error pointer in the msm_fbdev_create error path
Browse files Browse the repository at this point in the history
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 <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>
  • Loading branch information
Emil Velikov authored and Rob Clark committed Apr 19, 2018
1 parent a4af892 commit 789d4c3
Showing 1 changed file with 2 additions and 9 deletions.
11 changes: 2 additions & 9 deletions drivers/gpu/drm/msm/msm_fbdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
}

Expand Down

0 comments on commit 789d4c3

Please sign in to comment.