Skip to contentSkip to conversation

FAILED: patch "[PATCH] mm, slub: fix potential memoryleak in kmem_cache_open()" failed to apply to 4.14-stable tree

PATCH [email protected] 1 participant 1 message Oct 24, 2021

Subsystems (3)
lore
Share & tools
lore

[email protected]

author maintainer
#0 lore raw

The patch below does not apply to the 4.14-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.

thanks,

greg k-h

------------------ original commit in Linus's tree ------------------

From 9037c57681d25e4dcc442d940d6dbe24dd31f461 Mon Sep 17 00:00:00 2001
From: Miaohe Lin <[email protected]>
Date: Mon, 18 Oct 2021 15:15:59 -0700
Subject: [PATCH] mm, slub: fix potential memoryleak in kmem_cache_open()

In error path, the random_seq of slub cache might be leaked. Fix this by using __kmem_cache_release() to release all the relevant resources.

Fixes 210e7a43fa90 ("mm: SLUB freelist randomization")
Cc Andrey Konovalov <[email protected]>
Cc Andrey Ryabinin <[email protected]>
Cc Bharata B Rao <[email protected]>
Cc Christoph Lameter <[email protected]>
Cc David Rientjes <[email protected]>
Cc Faiyaz Mohammed <[email protected]>
Cc Greg Kroah-Hartman <[email protected]>
Cc Joonsoo Kim <[email protected]>
Cc Kees Cook <[email protected]>
Cc Pekka Enberg <[email protected]>
Cc Roman Gushchin <[email protected]>
mm/slub.c +1 -1
index a56a6423d4e8..bf1793fb4ce5 100644
@@ -4210,8 +4210,8 @@ static int kmem_cache_open(struct kmem_cache *s, slab_flags_t flags)
 	if (alloc_kmem_cache_cpus(s))
 		return 0;
 
-	free_kmem_cache_nodes(s);
 error:
+	__kmem_cache_release(s);
 	return -EINVAL;
 }