Commit 679caae1 authored by Matt Atwood's avatar Matt Atwood Committed by Jani Nikula

drm/i915: Fix memory leaks in scatterlist

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

Fixes: c3bfba9a ("drm/i915: Check for integer truncation on scatterlist creation")
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: default avatarMatt Atwood <matthew.s.atwood@intel.com>
Reviewed-by: default avatarHarish Chegondi <harish.chegondi@intel.com>
Signed-off-by: default avatarMatt 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 389b9d91)
Signed-off-by: default avatarJani Nikula <jani.nikula@intel.com>
parent fe7f56a7
......@@ -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);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment