Skip to content

Commit

Permalink
drm/i915: Fix memory leaks in i915 selftests
Browse files Browse the repository at this point in the history
[ Upstream commit 803033c ]

This patch fixes memory leaks on error escapes in function fake_get_pages

Fixes: c3bfba9 ("drm/i915: Check for integer truncation on scatterlist creation")
Signed-off-by: Cong Liu <liucong2@kylinos.cn>
Reviewed-by: Andrzej Hajda <andrzej.hajda@intel.com>
Reviewed-by: Andi Shyti <andi.shyti@linux.intel.com>
Signed-off-by: Andi Shyti <andi.shyti@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20230414224109.1051922-1-andi.shyti@linux.intel.com
(cherry picked from commit 8bfbdad)
Signed-off-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
Cong Liu authored and gregkh committed May 11, 2023
1 parent fd8b0ab commit 596d730
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion drivers/gpu/drm/i915/selftests/i915_gem_gtt.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 596d730

Please sign in to comment.