lkml.org 
[lkml]   [2022]   [Jun]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH v2] mm, slab: check the function kmalloc_slab return value
Date
As the possible failure of the kmalloc_slab,
it should be better to check it.

Signed-off-by: Ren Yu <renyu@nfschina.com>
Reported-by: kernel test robot <lkp@intel.com>
---
v2:
- change return value of error path to '-ENOMEM'
- not check for zero
---
mm/slab.c | 2 ++
1 file changed, 2 insertions(+)

diff --git a/mm/slab.c b/mm/slab.c
index f8cd00f4ba13..eb3fb042f4f4 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 (!cachep->freelist_cache)
+ return -ENOMEM;
}

err = setup_cpu_cache(cachep, gfp);
--
2.11.0
\
 
 \ /
  Last update: 2022-06-14 11:26    [W:0.158 / U:0.112 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site