From: Du, Changbin Date: Fri, 11 Nov 2016 02:31:37 +0000 (+0800) Subject: drm/i915/gvt: fix mem leakage in setup_vgpu_mmio for vgpu reset X-Git-Tag: v5.15~12311^2~21^2~39^2~6 X-Git-Url: https://git.proxmox.com/?a=commitdiff_plain;h=f4b0c2860b530e06ddaa5b5df31ab4171ac6e9eb;p=mirror_ubuntu-kernels.git drm/i915/gvt: fix mem leakage in setup_vgpu_mmio for vgpu reset Gvt gdrst handler handle_device_reset() invoke function setup_vgpu_mmio() to reset mmio status. In this case, the virtual mmio memory has been allocated already. The new allocation just cause old mmio memory leakage. Signed-off-by: Du, Changbin Signed-off-by: Zhenyu Wang --- diff --git a/drivers/gpu/drm/i915/gvt/vgpu.c b/drivers/gpu/drm/i915/gvt/vgpu.c index 3a15feadc1df..044125c0f407 100644 --- a/drivers/gpu/drm/i915/gvt/vgpu.c +++ b/drivers/gpu/drm/i915/gvt/vgpu.c @@ -46,9 +46,13 @@ int setup_vgpu_mmio(struct intel_vgpu *vgpu) struct intel_gvt *gvt = vgpu->gvt; const struct intel_gvt_device_info *info = &gvt->device_info; - vgpu->mmio.vreg = vzalloc(info->mmio_size * 2); - if (!vgpu->mmio.vreg) - return -ENOMEM; + if (vgpu->mmio.vreg) + memset(vgpu->mmio.vreg, 0, info->mmio_size * 2); + else { + vgpu->mmio.vreg = vzalloc(info->mmio_size * 2); + if (!vgpu->mmio.vreg) + return -ENOMEM; + } vgpu->mmio.sreg = vgpu->mmio.vreg + info->mmio_size;