drm/virtio: don't leak bo on drm_gem_object_init failure
authorGerd Hoffmann <kraxel@redhat.com>
Thu, 6 Apr 2017 15:59:40 +0000 (17:59 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 12 Jul 2017 13:01:03 +0000 (15:01 +0200)
commit 385aee965b4e4c36551c362a334378d2985b722a upstream.

Reported-by: 李强 <liqiang6-s@360.cn>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Link: http://patchwork.freedesktop.org/patch/msgid/20170406155941.458-1-kraxel@redhat.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/gpu/drm/virtio/virtgpu_object.c

index 1483daebe057d099dcaf05cfe964b241efec12f9..6f66b7347cd0d68c1257170e3521bbdd100bbaea 100644 (file)
@@ -81,8 +81,10 @@ int virtio_gpu_object_create(struct virtio_gpu_device *vgdev,
                return -ENOMEM;
        size = roundup(size, PAGE_SIZE);
        ret = drm_gem_object_init(vgdev->ddev, &bo->gem_base, size);
-       if (ret != 0)
+       if (ret != 0) {
+               kfree(bo);
                return ret;
+       }
        bo->dumb = false;
        virtio_gpu_init_ttm_placement(bo, pinned);