summaryrefslogtreecommitdiff
path: root/drivers/gpu/drm/virtio
diff options
context:
space:
mode:
authorColin Ian King <colin.king@canonical.com>2018-11-07 20:31:22 +0000
committerGerd Hoffmann <kraxel@redhat.com>2018-11-14 14:21:03 +0100
commit040b595a91b21b61d6e0d388394b79c85f614e7c (patch)
treef9d039d6ba4c638da8e0706c6969622f8cab6cde /drivers/gpu/drm/virtio
parent6862965261a09fc459815ba38efb758fc88006df (diff)
drm/virtio: fix memory leak of vfpriv on error return path
The allocation for vfpriv is being leaked on an error return path, fix this by kfree'ing it before returning. Detected by CoverityScan, CID#1475380 ("Resource Leak") Fixes: 6a37c49a94a9 ("drm/virtio: Handle context ID allocation errors") Signed-off-by: Colin Ian King <colin.king@canonical.com> Link: http://patchwork.freedesktop.org/patch/msgid/20181107203122.6861-1-colin.king@canonical.com Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Diffstat (limited to 'drivers/gpu/drm/virtio')
-rw-r--r--drivers/gpu/drm/virtio/virtgpu_kms.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/drivers/gpu/drm/virtio/virtgpu_kms.c b/drivers/gpu/drm/virtio/virtgpu_kms.c
index 8118f10fde4a..691b842d5f3a 100644
--- a/drivers/gpu/drm/virtio/virtgpu_kms.c
+++ b/drivers/gpu/drm/virtio/virtgpu_kms.c
@@ -267,8 +267,10 @@ int virtio_gpu_driver_open(struct drm_device *dev, struct drm_file *file)
get_task_comm(dbgname, current);
id = virtio_gpu_context_create(vgdev, strlen(dbgname), dbgname);
- if (id < 0)
+ if (id < 0) {
+ kfree(vfpriv);
return id;
+ }
vfpriv->ctx_id = id;
file->driver_priv = vfpriv;