Skip to content

Commit

Permalink
drm/vmwgfx: reorder framebuffer init sequence
Browse files Browse the repository at this point in the history
vmwgfx has an oddity, when failing to reference the surface it'll
return 0, since that's what the successfull drm_framebuffer_init will
leave behind in ret. Fix this up by returning -EINVAL.

Split out from all the other driver updates due to the above tiny
semantic change. Shouldn't matter though since the reference grabbing
seemingly can't fail.

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
  • Loading branch information
Daniel Vetter committed Jan 20, 2013
1 parent c7d73f6 commit 80f0b5a
Showing 1 changed file with 16 additions and 14 deletions.
30 changes: 16 additions & 14 deletions drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
Original file line number Diff line number Diff line change
Expand Up @@ -681,14 +681,10 @@ static int vmw_kms_new_framebuffer_surface(struct vmw_private *dev_priv,
goto out_err1;
}

ret = drm_framebuffer_init(dev, &vfbs->base.base,
&vmw_framebuffer_surface_funcs);
if (ret)
goto out_err2;

if (!vmw_surface_reference(surface)) {
DRM_ERROR("failed to reference surface %p\n", surface);
goto out_err3;
ret = -EINVAL;
goto out_err2;
}

/* XXX get the first 3 from the surface info */
Expand All @@ -707,10 +703,15 @@ static int vmw_kms_new_framebuffer_surface(struct vmw_private *dev_priv,

*out = &vfbs->base;

ret = drm_framebuffer_init(dev, &vfbs->base.base,
&vmw_framebuffer_surface_funcs);
if (ret)
goto out_err3;

return 0;

out_err3:
drm_framebuffer_cleanup(&vfbs->base.base);
vmw_surface_unreference(&surface);
out_err2:
kfree(vfbs);
out_err1:
Expand Down Expand Up @@ -1053,14 +1054,10 @@ static int vmw_kms_new_framebuffer_dmabuf(struct vmw_private *dev_priv,
goto out_err1;
}

ret = drm_framebuffer_init(dev, &vfbd->base.base,
&vmw_framebuffer_dmabuf_funcs);
if (ret)
goto out_err2;

if (!vmw_dmabuf_reference(dmabuf)) {
DRM_ERROR("failed to reference dmabuf %p\n", dmabuf);
goto out_err3;
ret = -EINVAL;
goto out_err2;
}

vfbd->base.base.bits_per_pixel = mode_cmd->bpp;
Expand All @@ -1077,10 +1074,15 @@ static int vmw_kms_new_framebuffer_dmabuf(struct vmw_private *dev_priv,
vfbd->base.user_handle = mode_cmd->handle;
*out = &vfbd->base;

ret = drm_framebuffer_init(dev, &vfbd->base.base,
&vmw_framebuffer_dmabuf_funcs);
if (ret)
goto out_err3;

return 0;

out_err3:
drm_framebuffer_cleanup(&vfbd->base.base);
vmw_dmabuf_unreference(&dmabuf);
out_err2:
kfree(vfbd);
out_err1:
Expand Down

0 comments on commit 80f0b5a

Please sign in to comment.