public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/i915/gem: Add check for bitmap_zalloc()
@ 2023-07-28  1:58 Jiasheng Jiang
  2023-07-28  8:06 ` Tvrtko Ursulin
  0 siblings, 1 reply; 2+ messages in thread
From: Jiasheng Jiang @ 2023-07-28  1:58 UTC (permalink / raw)
  To: jani.nikula, joonas.lahtinen, rodrigo.vivi, tvrtko.ursulin,
	airlied, daniel, robdclark, lucas.demarchi, thomas.hellstrom,
	chris
  Cc: intel-gfx, dri-devel, linux-kernel, Jiasheng Jiang

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@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


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

end of thread, other threads:[~2023-07-28  8:07 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-07-28  1:58 [PATCH] drm/i915/gem: Add check for bitmap_zalloc() Jiasheng Jiang
2023-07-28  8:06 ` Tvrtko Ursulin

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