[PATCH] drm/i915/gem: Add check for bitmap_zalloc()

Jiasheng Jiang jiasheng at iscas.ac.cn
Fri Jul 28 01:58:46 UTC 2023


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 at iscas.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



More information about the dri-devel mailing list