linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH][drm-next] drm/virtio: fix memory leak of vfpriv on error return path
@ 2018-11-07 20:31 Colin King
  2018-11-14 12:14 ` Gerd Hoffmann
  0 siblings, 1 reply; 2+ messages in thread
From: Colin King @ 2018-11-07 20:31 UTC (permalink / raw)
  To: David Airlie, Gerd Hoffmann, dri-devel, virtualization
  Cc: kernel-janitors, linux-kernel

From: Colin Ian King <colin.king@canonical.com>

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>
---
 drivers/gpu/drm/virtio/virtgpu_kms.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/virtio/virtgpu_kms.c b/drivers/gpu/drm/virtio/virtgpu_kms.c
index bf609dcae224..f4f995639ed1 100644
--- a/drivers/gpu/drm/virtio/virtgpu_kms.c
+++ b/drivers/gpu/drm/virtio/virtgpu_kms.c
@@ -266,8 +266,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;
-- 
2.19.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-11-14 12:14 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-07 20:31 [PATCH][drm-next] drm/virtio: fix memory leak of vfpriv on error return path Colin King
2018-11-14 12:14 ` Gerd Hoffmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).