Skip to contentSkip to conversation

drm/i915/gvt/kvmgt: remove some dead code

PATCH Superseded Dan Carpenter 3 participants 6 messages Feb 7, 2017 – Feb 9, 2017

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

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
index 3f656e3a6e5a..de2a55178a37 100644
@@ -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

maintainer
#1 lore raw
Quoted 4 lines · Dan Carpenter

If "caps.buf" is already NULL then it doesn't need to be freed or set to NULL.

<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
#2 lore raw
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.

<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

#3 lore raw

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
index 3f656e3a6e5a..773a45aa18f8 100644
@@ -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

maintainer Reviewed-by on v2 1/1
#4 lore raw
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.

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
#5 lore raw
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.

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