[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20231204080646.3299620-1-alexious@zju.edu.cn>
Date: Mon, 4 Dec 2023 16:06:46 +0800
From: Zhipeng Lu <alexious@....edu.cn>
To: alexious@....edu.cn
Cc: Zack Rusin <zackr@...are.com>,
VMware Graphics Reviewers
<linux-graphics-maintainer@...are.com>,
Maarten Lankhorst <maarten.lankhorst@...ux.intel.com>,
Maxime Ripard <mripard@...nel.org>,
Thomas Zimmermann <tzimmermann@...e.de>,
David Airlie <airlied@...il.com>,
Daniel Vetter <daniel@...ll.ch>,
Christian König <christian.koenig@....com>,
Matthew Auld <matthew.auld@...el.com>,
dri-devel@...ts.freedesktop.org, linux-kernel@...r.kernel.org
Subject: [PATCH] drm/vmwgfx: fix a memleak in vmw_gmrid_man_get_node
When ida_alloc_max fails, resources allocated before should be freed,
including *res allocated by kmalloc and ttm_resource_init.
Fixes: d3bcb4b02fe9 ("drm/vmwgfx: switch the TTM backends to self alloc")
Signed-off-by: Zhipeng Lu <alexious@....edu.cn>
---
drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c b/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c
index ceb4d3d3b965..220561b73493 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c
@@ -65,6 +65,8 @@ static int vmw_gmrid_man_get_node(struct ttm_resource_manager *man,
id = ida_alloc_max(&gman->gmr_ida, gman->max_gmr_ids - 1, GFP_KERNEL);
if (id < 0)
+ ttm_resource_fini(man, *res);
+ kfree(*res);
return id;
spin_lock(&gman->lock);
--
2.34.1
Powered by blists - more mailing lists