]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
drm/i915/gvt: fix memory leak in intel_vgpu_ioctl()
authorYi Wang <wang.yi59@zte.com.cn>
Wed, 8 Aug 2018 15:10:57 +0000 (23:10 +0800)
committerZhenyu Wang <zhenyuw@linux.intel.com>
Tue, 14 Aug 2018 07:27:12 +0000 (15:27 +0800)
The 'sparse' variable may leak when return in function
intel_vgpu_ioctl(), and this patch fix this.

Signed-off-by: Yi Wang <wang.yi59@zte.com.cn>
Reviewed-by: Jiang Biao <jiang.biao2@zte.com.cn>
Signed-off-by: Zhenyu Wang <zhenyuw@linux.intel.com>
drivers/gpu/drm/i915/gvt/kvmgt.c

index 9ba70826737aba9a1ed6b574c94d19df5751bf7d..a45f46d8537f15bd187fd4195d7de2c6b6dffd2a 100644 (file)
@@ -1257,11 +1257,13 @@ 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)
+                               if (ret) {
+                                       kfree(sparse);
                                        return ret;
+                               }
                                break;
                        default:
+                               kfree(sparse);
                                return -EINVAL;
                        }
                }
@@ -1277,6 +1279,7 @@ static long intel_vgpu_ioctl(struct mdev_device *mdev, unsigned int cmd,
                                                  sizeof(info), caps.buf,
                                                  caps.size)) {
                                        kfree(caps.buf);
+                                       kfree(sparse);
                                        return -EFAULT;
                                }
                                info.cap_offset = sizeof(info);
@@ -1285,6 +1288,7 @@ static long intel_vgpu_ioctl(struct mdev_device *mdev, unsigned int cmd,
                        kfree(caps.buf);
                }
 
+               kfree(sparse);
                return copy_to_user((void __user *)arg, &info, minsz) ?
                        -EFAULT : 0;
        } else if (cmd == VFIO_DEVICE_GET_IRQ_INFO) {