Commit a80abfbb authored by Linus Torvalds's avatar Linus Torvalds
Browse files
Pull slab fix from Vlastimil Babka:

 - Fix for potential infinite loop in kmalloc_nolock() when debugging
   is enabled for the cache (Vlastimil Babka)

* tag 'slab-for-6.18-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/vbabka/slab:
  slab: prevent infinite loop in kmalloc_nolock() with debugging
parents 9dc52063 c379b745
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -4666,8 +4666,12 @@ static void *___slab_alloc(struct kmem_cache *s, gfp_t gfpflags, int node,
	if (kmem_cache_debug(s)) {
		freelist = alloc_single_from_new_slab(s, slab, orig_size, gfpflags);

		if (unlikely(!freelist))
		if (unlikely(!freelist)) {
			/* This could cause an endless loop. Fail instead. */
			if (!allow_spin)
				return NULL;
			goto new_objects;
		}

		if (s->flags & SLAB_STORE_USER)
			set_track(s, freelist, TRACK_ALLOC, addr,