diff options
author | Zhi Wang <zhi.a.wang@intel.com> | 2017-09-10 16:36:21 +0300 |
---|---|---|
committer | Zhenyu Wang <zhenyuw@linux.intel.com> | 2017-11-16 06:46:50 +0300 |
commit | bf4097ea5762bd90d836df9904594eb4822fefa7 (patch) | |
tree | 784b0f88f341672605225cf86514f3609ccb7168 /drivers/gpu/drm/i915/gvt/cmd_parser.c | |
parent | 91d5d85442b2a65e5f4e1726565c1c1a8ba9976f (diff) | |
download | linux-bf4097ea5762bd90d836df9904594eb4822fefa7.tar.xz |
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: Zhi Wang <zhi.a.wang@intel.com>
Diffstat (limited to 'drivers/gpu/drm/i915/gvt/cmd_parser.c')
-rw-r--r-- | drivers/gpu/drm/i915/gvt/cmd_parser.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/drivers/gpu/drm/i915/gvt/cmd_parser.c b/drivers/gpu/drm/i915/gvt/cmd_parser.c index 701a3c6f1669..9405a214760c 100644 --- a/drivers/gpu/drm/i915/gvt/cmd_parser.c +++ b/drivers/gpu/drm/i915/gvt/cmd_parser.c @@ -2620,14 +2620,16 @@ static int shadow_workload_ring_buffer(struct intel_vgpu_workload *workload) gma_top = workload->rb_start + guest_rb_size; 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 */ - vgpu->reserve_ring_buffer_va[ring_id] = - krealloc(va, workload->rb_len, GFP_KERNEL); - if (!vgpu->reserve_ring_buffer_va[ring_id]) { + va = vgpu->reserve_ring_buffer_va[ring_id]; + p = krealloc(va, workload->rb_len, GFP_KERNEL); + if (!p) { gvt_vgpu_err("fail to alloc reserve ring buffer\n"); return -ENOMEM; } + vgpu->reserve_ring_buffer_va[ring_id] = p; vgpu->reserve_ring_buffer_size[ring_id] = workload->rb_len; } |