⬢ DragonFlyBSD Kernel Audit
DF-5192 / fix.diff
← back to finding ↓ download raw
--- a/sys/dev/drm/i915/i915_gem_batch_pool.c
+++ b/sys/dev/drm/i915/i915_gem_batch_pool.c
@@ -92,6 +92,8 @@
 	 * 16KiB into the same bucket: i.e. the the buckets hold objects of
 	 * (1 page, 2 pages, 4 pages, 8+ pages).
 	 */
 	n = fls(size >> PAGE_SHIFT) - 1;
+	if (n < 0) /* fls(0) == 0: size < PAGE_SIZE must land in bucket 0 */
+		n = 0;
 	if (n >= ARRAY_SIZE(pool->cache_list))
 		n = ARRAY_SIZE(pool->cache_list) - 1;
 	list = &pool->cache_list[n];