[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20230728015846.20228-1-jiasheng@iscas.ac.cn>
Date: Fri, 28 Jul 2023 09:58:46 +0800
From: Jiasheng Jiang <jiasheng@...as.ac.cn>
To: jani.nikula@...ux.intel.com, joonas.lahtinen@...ux.intel.com,
rodrigo.vivi@...el.com, tvrtko.ursulin@...ux.intel.com,
airlied@...il.com, daniel@...ll.ch, robdclark@...omium.org,
lucas.demarchi@...el.com, thomas.hellstrom@...ux.intel.com,
chris@...is-wilson.co.uk
Cc: intel-gfx@...ts.freedesktop.org, dri-devel@...ts.freedesktop.org,
linux-kernel@...r.kernel.org, Jiasheng Jiang <jiasheng@...as.ac.cn>
Subject: [PATCH] drm/i915/gem: Add check for bitmap_zalloc()
Add the check for the return value of bitmap_zalloc() in order to
guarantee the success of the allocation.
Fixes: e9b73c67390a ("drm/i915: Reduce memory pressure during shrinker by preallocating swizzle pages")
Signed-off-by: Jiasheng Jiang <jiasheng@...as.ac.cn>
---
drivers/gpu/drm/i915/gem/i915_gem_tiling.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/drivers/gpu/drm/i915/gem/i915_gem_tiling.c b/drivers/gpu/drm/i915/gem/i915_gem_tiling.c
index a049ca0b7980..e9cf99d95966 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_tiling.c
+++ b/drivers/gpu/drm/i915/gem/i915_gem_tiling.c
@@ -311,6 +311,11 @@ i915_gem_object_set_tiling(struct drm_i915_gem_object *obj,
if (!obj->bit_17) {
obj->bit_17 = bitmap_zalloc(obj->base.size >> PAGE_SHIFT,
GFP_KERNEL);
+ if (!obj->bit_17) {
+ i915_gem_object_unlock(obj);
+ i915_gem_object_release_mmap_gtt(obj);
+ return -ENOMEM;
+ }
}
} else {
bitmap_free(obj->bit_17);
--
2.25.1
Powered by blists - more mailing lists