[PATCH v2] drm/i915: Fix memory leaks in i915 selftests

Andi Shyti andi.shyti at linux.intel.com
Fri Apr 14 22:41:09 UTC 2023


From: Cong Liu <liucong2 at kylinos.cn>

This patch fixes memory leaks on error escapes in function fake_get_pages

Fixes: c3bfba9a2225 ("drm/i915: Check for integer truncation on scatterlist creation")
Signed-off-by: Cong Liu <liucong2 at kylinos.cn>
Reviewed-by: Andrzej Hajda <andrzej.hajda at intel.com>
Reviewed-by: Andi Shyti <andi.shyti at linux.intel.com>
Signed-off-by: Andi Shyti <andi.shyti at linux.intel.com>
---
Hi,

just resending this patch as I don't see it in our patchwork.

Andi

Changelong
==========
v1 -> v2
 - Add r-b tags

 drivers/gpu/drm/i915/selftests/i915_gem_gtt.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/i915/selftests/i915_gem_gtt.c b/drivers/gpu/drm/i915/selftests/i915_gem_gtt.c
index 5361ce70d3f29..154801f1c4685 100644
--- a/drivers/gpu/drm/i915/selftests/i915_gem_gtt.c
+++ b/drivers/gpu/drm/i915/selftests/i915_gem_gtt.c
@@ -69,8 +69,10 @@ static int fake_get_pages(struct drm_i915_gem_object *obj)
 
 	rem = round_up(obj->base.size, BIT(31)) >> 31;
 	/* restricted by sg_alloc_table */
-	if (overflows_type(rem, unsigned int))
+	if (overflows_type(rem, unsigned int)) {
+		kfree(pages);
 		return -E2BIG;
+	}
 
 	if (sg_alloc_table(pages, rem, GFP)) {
 		kfree(pages);
-- 
2.39.2



More information about the dri-devel mailing list