From: Gerd Hoffmann Date: Thu, 6 Apr 2017 15:59:40 +0000 (+0200) Subject: drm/virtio: don't leak bo on drm_gem_object_init failure X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=385aee965b4e4c36551c362a334378d2985b722a;p=openwrt%2Fstaging%2Fblogic.git drm/virtio: don't leak bo on drm_gem_object_init failure Reported-by: 李强 Signed-off-by: Gerd Hoffmann Link: http://patchwork.freedesktop.org/patch/msgid/20170406155941.458-1-kraxel@redhat.com --- diff --git a/drivers/gpu/drm/virtio/virtgpu_object.c b/drivers/gpu/drm/virtio/virtgpu_object.c index 1483daebe057..6f66b7347cd0 100644 --- a/drivers/gpu/drm/virtio/virtgpu_object.c +++ b/drivers/gpu/drm/virtio/virtgpu_object.c @@ -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);