Skip to content

Commit

Permalink
drm/i915/gvt: destroy the allocated idr on vgpu creating failures
Browse files Browse the repository at this point in the history
Once idr_alloc gets called data is allocated within the idr list, if
any error occurs afterwards, we should undo that by idr_remove on the
error path.

Signed-off-by: Jike Song <jike.song@intel.com>
Signed-off-by: Zhenyu Wang <zhenyuw@linux.intel.com>
  • Loading branch information
Jike Song authored and Zhenyu Wang committed Jan 9, 2017
1 parent 59c0573 commit 4e53789
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion drivers/gpu/drm/i915/gvt/vgpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ static struct intel_vgpu *__intel_gvt_create_vgpu(struct intel_gvt *gvt,

ret = setup_vgpu_mmio(vgpu);
if (ret)
goto out_free_vgpu;
goto out_clean_idr;

ret = intel_vgpu_alloc_resource(vgpu, param);
if (ret)
Expand Down Expand Up @@ -355,6 +355,8 @@ static struct intel_vgpu *__intel_gvt_create_vgpu(struct intel_gvt *gvt,
intel_vgpu_free_resource(vgpu);
out_clean_vgpu_mmio:
clean_vgpu_mmio(vgpu);
out_clean_idr:
idr_remove(&gvt->vgpu_idr, vgpu->id);
out_free_vgpu:
vfree(vgpu);
mutex_unlock(&gvt->lock);
Expand Down

0 comments on commit 4e53789

Please sign in to comment.