Skip to content

Commit

Permalink
drm/virtio: fix memory leak of vfpriv on error return path
Browse files Browse the repository at this point in the history
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: 6a37c49 ("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>
  • Loading branch information
Colin Ian King authored and Gerd Hoffmann committed Nov 14, 2018
1 parent 6862965 commit 040b595
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion drivers/gpu/drm/virtio/virtgpu_kms.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 040b595

Please sign in to comment.