linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mm: check the function kmalloc_slab return value
@ 2022-06-13 10:24 Ren Yu
  2022-06-13 13:37 ` kernel test robot
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Ren Yu @ 2022-06-13 10:24 UTC (permalink / raw)
  To: cl
  Cc: penberg, rientjes, iamjoonsoo.kim, akpm, vbabka, roman.gushchin,
	42.hyeyoo, linux-mm, linux-kernel, liqiong, qixu, hukun, yuzhe,
	Ren Yu

As the possible failure of the kmalloc_slab,
it should be better to check it.

Signed-off-by: Ren Yu <renyu@nfschina.com>
---
 mm/slab.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/mm/slab.c b/mm/slab.c
index f8cd00f4ba13..72135e555827 100644
--- a/mm/slab.c
+++ b/mm/slab.c
@@ -2064,6 +2064,8 @@ int __kmem_cache_create(struct kmem_cache *cachep, slab_flags_t flags)
 	if (OFF_SLAB(cachep)) {
 		cachep->freelist_cache =
 			kmalloc_slab(cachep->freelist_size, 0u);
+		if (unlikely(ZERO_OR_NULL_PTR(cachep->freelist_cache)))
+			return cachep->freelist_cache;
 	}
 
 	err = setup_cpu_cache(cachep, gfp);
-- 
2.11.0



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

end of thread, other threads:[~2022-06-14 11:47 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-13 10:24 [PATCH] mm: check the function kmalloc_slab return value Ren Yu
2022-06-13 13:37 ` kernel test robot
2022-06-14  8:39 ` Ren Yu
2022-06-14  8:48   ` Vlastimil Babka
2022-06-14  9:26     ` tury
2022-06-14 11:47       ` Vlastimil Babka
2022-06-14  9:23 ` [PATCH v2] mm, slab: " Ren Yu

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