Skip to content

Commit

Permalink
drm/gma500: fix double freeing
Browse files Browse the repository at this point in the history
We are allocating backing using psbfb_alloc() and so
backing->stolen is always true. So we were freeing backing two times.
Moreover if we follow the execution path then we should be freeing
backing after we have released the helper. So remove the one which frees
backing before the helper is released.
While at it the error labels are also renamed to give a meaningful
name.

[Patrik: Fixed conflict with removal of struct_mutex]

Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org>
Reviewed-by: Patrik Jakobsson <patrik.r.jakobsson@gmail.com>
Signed-off-by: Patrik Jakobsson <patrik.r.jakobsson@gmail.com>
  • Loading branch information
sudipm-mukherjee authored and patjak committed Apr 8, 2016
1 parent d00b39c commit 4cd54d9
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions drivers/gpu/drm/gma500/framebuffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -411,15 +411,15 @@ static int psbfb_create(struct psb_fbdev *fbdev,
info = drm_fb_helper_alloc_fbi(&fbdev->psb_fb_helper);
if (IS_ERR(info)) {
ret = PTR_ERR(info);
goto out_err1;
goto err_free_range;
}
info->par = fbdev;

mode_cmd.pixel_format = drm_mode_legacy_fb_format(bpp, depth);

ret = psb_framebuffer_init(dev, psbfb, &mode_cmd, backing);
if (ret)
goto out_unref;
goto err_release;

fb = &psbfb->base;
psbfb->fbdev = info;
Expand Down Expand Up @@ -464,14 +464,9 @@ static int psbfb_create(struct psb_fbdev *fbdev,
psbfb->base.width, psbfb->base.height);

return 0;
out_unref:
if (backing->stolen)
psb_gtt_free_range(dev, backing);
else
drm_gem_object_unreference_unlocked(&backing->gem);

err_release:
drm_fb_helper_release_fbi(&fbdev->psb_fb_helper);
out_err1:
err_free_range:
psb_gtt_free_range(dev, backing);
return ret;
}
Expand Down

0 comments on commit 4cd54d9

Please sign in to comment.