Commit bf4097ea authored by Zhi Wang's avatar Zhi Wang Committed by Zhenyu Wang

drm/i915/gvt: Fix a memory leak in cmd_parser.c

The pointer points to the original memory can never take the return value
of krealloc().
Signed-off-by: default avatarZhi Wang <zhi.a.wang@intel.com>
parent 91d5d854
...@@ -2620,14 +2620,16 @@ static int shadow_workload_ring_buffer(struct intel_vgpu_workload *workload) ...@@ -2620,14 +2620,16 @@ static int shadow_workload_ring_buffer(struct intel_vgpu_workload *workload)
gma_top = workload->rb_start + guest_rb_size; gma_top = workload->rb_start + guest_rb_size;
if (workload->rb_len > vgpu->reserve_ring_buffer_size[ring_id]) { if (workload->rb_len > vgpu->reserve_ring_buffer_size[ring_id]) {
void *va = vgpu->reserve_ring_buffer_va[ring_id]; void *va, *p;
/* realloc the new ring buffer if needed */ /* realloc the new ring buffer if needed */
vgpu->reserve_ring_buffer_va[ring_id] = va = vgpu->reserve_ring_buffer_va[ring_id];
krealloc(va, workload->rb_len, GFP_KERNEL); p = krealloc(va, workload->rb_len, GFP_KERNEL);
if (!vgpu->reserve_ring_buffer_va[ring_id]) { if (!p) {
gvt_vgpu_err("fail to alloc reserve ring buffer\n"); gvt_vgpu_err("fail to alloc reserve ring buffer\n");
return -ENOMEM; return -ENOMEM;
} }
vgpu->reserve_ring_buffer_va[ring_id] = p;
vgpu->reserve_ring_buffer_size[ring_id] = workload->rb_len; vgpu->reserve_ring_buffer_size[ring_id] = workload->rb_len;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment