Skip to content

Commit 679caae

Browse files
msatwoodjnikula
authored andcommitted
drm/i915: Fix memory leaks in scatterlist
This patch fixes memory leaks on error escapes in i915_scatterlist.c Fixes: c3bfba9 ("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> Reviewed-by: Harish Chegondi <harish.chegondi@intel.com> Signed-off-by: Matt Roper <matthew.d.roper@intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/20230201232801.123684-1-matthew.s.atwood@intel.com (cherry picked from commit 389b9d9) Signed-off-by: Jani Nikula <jani.nikula@intel.com>
1 parent fe7f56a commit 679caae

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

drivers/gpu/drm/i915/i915_scatterlist.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,10 @@ struct i915_refct_sgt *i915_rsgt_from_mm_node(const struct drm_mm_node *node,
9898
st = &rsgt->table;
9999
/* restricted by sg_alloc_table */
100100
if (WARN_ON(overflows_type(DIV_ROUND_UP_ULL(node->size, segment_pages),
101-
unsigned int)))
101+
unsigned int))) {
102+
i915_refct_sgt_put(rsgt);
102103
return ERR_PTR(-E2BIG);
104+
}
103105

104106
if (sg_alloc_table(st, DIV_ROUND_UP_ULL(node->size, segment_pages),
105107
GFP_KERNEL)) {
@@ -183,8 +185,10 @@ struct i915_refct_sgt *i915_rsgt_from_buddy_resource(struct ttm_resource *res,
183185
i915_refct_sgt_init(rsgt, size);
184186
st = &rsgt->table;
185187
/* restricted by sg_alloc_table */
186-
if (WARN_ON(overflows_type(PFN_UP(res->size), unsigned int)))
188+
if (WARN_ON(overflows_type(PFN_UP(res->size), unsigned int))) {
189+
i915_refct_sgt_put(rsgt);
187190
return ERR_PTR(-E2BIG);
191+
}
188192

189193
if (sg_alloc_table(st, PFN_UP(res->size), GFP_KERNEL)) {
190194
i915_refct_sgt_put(rsgt);

0 commit comments

Comments
 (0)