From: Cyrill Gorcunov Fix possible NULL pointer dereference if kzalloc failed. To be able to return proper error code the function return type is changed to ssize_t (according to callees and sysfs definitions). Signed-off-by: Cyrill Gorcunov Reviewed-by: Pekka Enberg Cc: Christoph Lameter Signed-off-by: Andrew Morton --- mm/slub.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff -puN mm/slub.c~slub-fix-possible-null-pointer-dereference mm/slub.c --- a/mm/slub.c~slub-fix-possible-null-pointer-dereference +++ a/mm/slub.c @@ -274,7 +274,7 @@ static inline struct kmem_cache_cpu *get } /* Determine the maximum number of objects that a slab page can hold */ -static inline unsigned long slab_objects(struct kmem_cache *s, struct page *page) +static inline ssize_t slab_objects(struct kmem_cache *s, struct page *page) { if (PageCompound(page)) return page[1].inuse; @@ -3586,6 +3586,8 @@ static unsigned long show_slab_objects(s unsigned long *per_cpu; nodes = kzalloc(2 * sizeof(unsigned long) * nr_node_ids, GFP_KERNEL); + if (!nodes) + return -ENOMEM; per_cpu = nodes + nr_node_ids; for_each_possible_cpu(cpu) { _