drm/i915/gvt/kvmgt: remove some dead code
PATCH 1/1 drm/i915/gvt/kvmgt: remove some dead code
If "caps.buf" is already NULL then it doesn't need to be freed or set to NULL.
drivers/gpu/drm/i915/gvt/kvmgt.c +1 -4
@@ -965,11 +965,8 @@ static long intel_vgpu_ioctl(struct mdev_device *mdev, unsigned int cmd, sparse->areas[0 ].offset =PAGE_ALIGN (vgpu_aperture_offset (vgpu)); sparse->areas[0 ].size =vgpu_aperture_sz (vgpu); -if (!caps.buf) { -kfree (caps.buf); - caps.buf =NULL ; +if (!caps.buf) caps.size =0 ; - }break ; case VFIO_PCI_BAR3_REGION_INDEX ... VFIO_PCI_BAR5_REGION_INDEX:
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Joonas Lahtinen
maintainerQuoted 4 lines · Dan Carpenter
If "caps.buf" is already NULL then it doesn't need to be freed or set to NULL.
Signed-off-by Dan Carpenter <[email protected]>
<SNIP>
drivers/gpu/drm/i915/gvt/kvmgt.c static long intel_vgpu_ioctl(struct mdev_device *mdev, unsigned int cmd, · line 968
Quoted 5 lines
(quoted diff) +0
-0@@ -965,11 +965,8 @@ static long intel_vgpu_ioctl(struct mdev_device *mdev, unsigned int cmd,sparse->areas[0].offset = PAGE_ALIGN(vgpu_aperture_offset(vgpu)); sparse->areas[0].size =
vgpu_aperture_sz(vgpu);drivers/gpu/drm/i915/gvt/kvmgt.c +0
-1-if (!caps.buf) {
Looking at the code around, the right thing would be to just remove the negation? This currently seems like a memory leak.
drivers/gpu/drm/i915/gvt/kvmgt.c static long intel_vgpu_ioctl(struct mdev_device *mdev, unsigned int cmd, · line 972
Quoted 5 lines
drivers/gpu/drm/i915/gvt/kvmgt.c +1
-2-kfree (caps.buf); - caps.buf =NULL ; +if (!caps.buf)caps.size = 0;
drivers/gpu/drm/i915/gvt/kvmgt.c +0
-1- }
And quickly looking, the caps is pre-initialized but unused at this point, so the whole if could just be removed, right?
Regards, Joonas
Signature · 7 lines
Joonas Lahtinen Open Source Technology Center Intel Corporation _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 17 lines · Joonas Lahtinen
Quoted 4 lines · Dan Carpenter
If "caps.buf" is already NULL then it doesn't need to be freed or set to NULL.
Signed-off-by Dan Carpenter <[email protected]><SNIP>
drivers/gpu/drm/i915/gvt/kvmgt.c static long intel_vgpu_ioctl(struct mdev_device *mdev, unsigned int cmd, · line 968
Quoted 5 lines
(quoted diff) +0
-0@@ -965,11 +965,8 @@ static long intel_vgpu_ioctl(struct mdev_device *mdev, unsigned int cmd,sparse->areas[0].offset = PAGE_ALIGN(vgpu_aperture_offset(vgpu)); sparse->areas[0].size =
vgpu_aperture_sz(vgpu);drivers/gpu/drm/i915/gvt/kvmgt.c +0
-1-if (!caps.buf) {Looking at the code around, the right thing would be to just remove the negation? This currently seems like a memory leak.
Quoted 8 lines
drivers/gpu/drm/i915/gvt/kvmgt.c static long intel_vgpu_ioctl(struct mdev_device *mdev, unsigned int cmd, · line 972
Quoted 5 lines
drivers/gpu/drm/i915/gvt/kvmgt.c +1
-2-kfree (caps.buf); - caps.buf =NULL ; +if (!caps.buf)caps.size = 0;
drivers/gpu/drm/i915/gvt/kvmgt.c +0
-1- }And quickly looking, the caps is pre-initialized but unused at this point, so the whole if could just be removed, right?
Hm... Duh. You're right. Let me resend.
regards,
dan carpenter
PATCH v2 1/1 drm/i915/gvt/kvmgt: remove some dead code
In reply to Joonas Lahtinen"caps.buf" is always NULL here and "caps.size" is always zero. The code is a no-op and can be removed.
drivers/gpu/drm/i915/gvt/kvmgt.c +0 -5
@@ -965,11 +965,6 @@ static long intel_vgpu_ioctl(struct mdev_device *mdev, unsigned int cmd, sparse->areas[0 ].offset =PAGE_ALIGN (vgpu_aperture_offset (vgpu)); sparse->areas[0 ].size =vgpu_aperture_sz (vgpu); -if (!caps.buf) { -kfree (caps.buf); - caps.buf =NULL ; - caps.size =0 ; - }break ; case VFIO_PCI_BAR3_REGION_INDEX ... VFIO_PCI_BAR5_REGION_INDEX:
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 4 lines · Dan Carpenter
"caps.buf" is always NULL here and "caps.size" is always zero. The code is a no-op and can be removed.
Signed-off-by Dan Carpenter <[email protected]>
I assume Zhenyu will merge this through their tree.
Regards, Joonas
Signature · 7 lines
Joonas Lahtinen Open Source Technology Center Intel Corporation _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 10 lines · Joonas Lahtinen
Quoted 4 lines · Dan Carpenter
"caps.buf" is always NULL here and "caps.size" is always zero. The code is a no-op and can be removed.
Signed-off-by Dan Carpenter <[email protected]>Reviewed-by Joonas Lahtinen <[email protected]>I assume Zhenyu will merge this through their tree.
yeah, already put in queue. Thanks!
Signature · 3 lines
Open Source Technology Center, Intel ltd. $gpg --keyserver wwwkeys.pgp.net --recv-keys 4D781827
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel