[PATCH] mm: check the function kmalloc_slab return value

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

Signed-off-by: Ren Yu <renyu@xxxxxxxxxxxx>
---
 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





[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux