Intel-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [Intel-gfx] [PATCH] drm/i915: Fix memory leaks in scatterlist
@ 2023-02-01 23:28 Matt Atwood
  2023-02-02  1:02 ` [Intel-gfx] ✓ Fi.CI.BAT: success for " Patchwork
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Matt Atwood @ 2023-02-01 23:28 UTC (permalink / raw)
  To: intel-gfx

This patch fixes memory leaks on error escapes in i915_scatterlist.c

Fixes: c3bfba9a2225 ("drm/i915: Check for integer truncation on scatterlist creation")
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Matt Atwood <matthew.s.atwood@intel.com>
---
 drivers/gpu/drm/i915/i915_scatterlist.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_scatterlist.c b/drivers/gpu/drm/i915/i915_scatterlist.c
index 756289e43dff6..7c7a86921b1c7 100644
--- a/drivers/gpu/drm/i915/i915_scatterlist.c
+++ b/drivers/gpu/drm/i915/i915_scatterlist.c
@@ -98,8 +98,10 @@ struct i915_refct_sgt *i915_rsgt_from_mm_node(const struct drm_mm_node *node,
 	st = &rsgt->table;
 	/* restricted by sg_alloc_table */
 	if (WARN_ON(overflows_type(DIV_ROUND_UP_ULL(node->size, segment_pages),
-				   unsigned int)))
+				   unsigned int))) {
+		i915_refct_sgt_put(rsgt);
 		return ERR_PTR(-E2BIG);
+	}
 
 	if (sg_alloc_table(st, DIV_ROUND_UP_ULL(node->size, segment_pages),
 			   GFP_KERNEL)) {
@@ -183,8 +185,10 @@ struct i915_refct_sgt *i915_rsgt_from_buddy_resource(struct ttm_resource *res,
 	i915_refct_sgt_init(rsgt, size);
 	st = &rsgt->table;
 	/* restricted by sg_alloc_table */
-	if (WARN_ON(overflows_type(PFN_UP(res->size), unsigned int)))
+	if (WARN_ON(overflows_type(PFN_UP(res->size), unsigned int))) {
+		i915_refct_sgt_put(rsgt);
 		return ERR_PTR(-E2BIG);
+	}
 
 	if (sg_alloc_table(st, PFN_UP(res->size), GFP_KERNEL)) {
 		i915_refct_sgt_put(rsgt);
-- 
2.39.1


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

end of thread, other threads:[~2023-02-06 16:56 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-02-01 23:28 [Intel-gfx] [PATCH] drm/i915: Fix memory leaks in scatterlist Matt Atwood
2023-02-02  1:02 ` [Intel-gfx] ✓ Fi.CI.BAT: success for " Patchwork
2023-02-02  7:55 ` [Intel-gfx] [PATCH] " Harish Chegondi
2023-02-03 23:10 ` [Intel-gfx] ✓ Fi.CI.BAT: success for drm/i915: Fix memory leaks in scatterlist (rev2) Patchwork
2023-02-05 11:20 ` [Intel-gfx] ✓ Fi.CI.IGT: " Patchwork
2023-02-06 16:56   ` Matt Roper

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox