Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 040b595a authored by Colin Ian King's avatar Colin Ian King Committed by Gerd Hoffmann
Browse files

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: 6a37c49a ("drm/virtio: Handle context ID allocation errors")
Signed-off-by: default avatarColin Ian King <colin.king@canonical.com>
Link: http://patchwork.freedesktop.org/patch/msgid/20181107203122.6861-1-colin.king@canonical.com


Signed-off-by: default avatarGerd Hoffmann <kraxel@redhat.com>
parent 68629652
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -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;