[PATCH 5/8] drm/i915/gvt: Fix check error on possible memory leak
Wang, Zhi A
zhi.a.wang at intel.com
Wed Feb 28 11:51:17 UTC 2018
Reviewed-by: Zhi Wang <zhi.a.wang at intel.com>
-----Original Message-----
From: intel-gvt-dev [mailto:intel-gvt-dev-bounces at lists.freedesktop.org] On Behalf Of Zhenyu Wang
Sent: Thursday, February 22, 2018 3:16 PM
To: intel-gvt-dev at lists.freedesktop.org
Subject: [PATCH 5/8] drm/i915/gvt: Fix check error on possible memory leak
Fix below check error by always remember to free.
CHECK drivers/gpu/drm/i915//gvt/kvmgt.c
drivers/gpu/drm/i915//gvt/kvmgt.c:1166 intel_vgpu_ioctl() warn: possible memory leak of 'sparse'
drivers/gpu/drm/i915//gvt/kvmgt.c:1181 intel_vgpu_ioctl() warn: possible memory leak of 'sparse'
drivers/gpu/drm/i915//gvt/kvmgt.c:1189 intel_vgpu_ioctl() warn: possible memory leak of 'sparse'
Signed-off-by: Zhenyu Wang <zhenyuw at linux.intel.com>
---
drivers/gpu/drm/i915/gvt/kvmgt.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/drivers/gpu/drm/i915/gvt/kvmgt.c b/drivers/gpu/drm/i915/gvt/kvmgt.c
index 21c711b10515..c9e9452c534e 100644
--- a/drivers/gpu/drm/i915/gvt/kvmgt.c
+++ b/drivers/gpu/drm/i915/gvt/kvmgt.c
@@ -1047,7 +1047,7 @@ static long intel_vgpu_ioctl(struct mdev_device *mdev, unsigned int cmd,
} else if (cmd == VFIO_DEVICE_GET_REGION_INFO) {
struct vfio_region_info info;
struct vfio_info_cap caps = { .buf = NULL, .size = 0 };
- int i, ret;
+ int i, ret = 0;
struct vfio_region_info_cap_sparse_mmap *sparse = NULL;
size_t size;
int nr_areas = 1;
@@ -1158,14 +1158,14 @@ static long intel_vgpu_ioctl(struct mdev_device *mdev, unsigned int cmd,
&sparse->header, sizeof(*sparse) +
(sparse->nr_areas *
sizeof(*sparse->areas)));
- kfree(sparse);
- if (ret)
- return ret;
break;
default:
- return -EINVAL;
+ ret = -EINVAL;
}
}
+ kfree(sparse);
+ if (ret)
+ return ret;
if (caps.size) {
info.flags |= VFIO_REGION_INFO_FLAG_CAPS;
--
2.16.1
_______________________________________________
intel-gvt-dev mailing list
intel-gvt-dev at lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gvt-dev
More information about the intel-gvt-dev
mailing list