linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] drm/qxl: fix a memory leak bug
@ 2019-08-19 18:08 Wenwen Wang
  2019-08-20  6:57 ` Gerd Hoffmann
  0 siblings, 1 reply; 2+ messages in thread
From: Wenwen Wang @ 2019-08-19 18:08 UTC (permalink / raw)
  To: Wenwen Wang
  Cc: Dave Airlie, Gerd Hoffmann, David Airlie, Daniel Vetter,
	open list:DRM DRIVER FOR QXL VIRTUAL GPU,
	open list:DRM DRIVER FOR QXL VIRTUAL GPU, open list:DRM DRIVERS,
	open list

In qxl_bo_create(), the temporary 'bo' is allocated through kzalloc().
However, it is not deallocated in the following execution if ttm_bo_init()
fails, leading to a memory leak bug. To fix this issue, free 'bo' before
returning the error.

Signed-off-by: Wenwen Wang <wenwen@cs.uga.edu>
---
 drivers/gpu/drm/qxl/qxl_object.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/gpu/drm/qxl/qxl_object.c b/drivers/gpu/drm/qxl/qxl_object.c
index 4928fa6..3b217fa 100644
--- a/drivers/gpu/drm/qxl/qxl_object.c
+++ b/drivers/gpu/drm/qxl/qxl_object.c
@@ -118,6 +118,7 @@ int qxl_bo_create(struct qxl_device *qdev,
 			dev_err(qdev->ddev.dev,
 				"object_init failed for (%lu, 0x%08X)\n",
 				size, domain);
+		kfree(bo);
 		return r;
 	}
 	*bo_ptr = bo;
-- 
2.7.4


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

* Re: [PATCH] drm/qxl: fix a memory leak bug
  2019-08-19 18:08 [PATCH] drm/qxl: fix a memory leak bug Wenwen Wang
@ 2019-08-20  6:57 ` Gerd Hoffmann
  0 siblings, 0 replies; 2+ messages in thread
From: Gerd Hoffmann @ 2019-08-20  6:57 UTC (permalink / raw)
  To: Wenwen Wang
  Cc: Dave Airlie, David Airlie, Daniel Vetter,
	open list:DRM DRIVER FOR QXL VIRTUAL GPU,
	open list:DRM DRIVER FOR QXL VIRTUAL GPU, open list:DRM DRIVERS,
	open list

On Mon, Aug 19, 2019 at 01:08:18PM -0500, Wenwen Wang wrote:
> In qxl_bo_create(), the temporary 'bo' is allocated through kzalloc().
> However, it is not deallocated in the following execution if ttm_bo_init()
> fails, leading to a memory leak bug. To fix this issue, free 'bo' before
> returning the error.

No.  ttm_bo_init() calls the destroy callback (qxl_ttm_bo_destroy for
qxl) on failure, which will properly cleanup 'bo' and also free it.

cheers,
  Gerd


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

end of thread, other threads:[~2019-08-20  6:57 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-19 18:08 [PATCH] drm/qxl: fix a memory leak bug Wenwen Wang
2019-08-20  6:57 ` 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).