lkml.org 
[lkml]   [2019]   [May]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[Patch] slub: Fix a missing-check bug in mm/slub.c file of Linux 5.1.1
Pointer s is allocated with kmem_cache_zalloc(). And s is used in the 
follwoing codes. However, when kmem_cache_zalloc fails, using s will
cause null pointer dereference and the kernel will go wrong. Thus we
check whether the kmem_cache_zalloc fails.

Signed-off-by: Gen Zhang <blackgod016574@gmail.com>

---
--- mm/slub.c
+++ mm/slub.c
@@ -4201,6 +4201,8 @@ static struct kmem_cache * __init bootst
{
int node;
struct kmem_cache *s = kmem_cache_zalloc(kmem_cache, GFP_NOWAIT);
+ if (!s)
+ return ERR_PTR(-ENOMEM);
struct kmem_cache_node *n;

memcpy(s, static_cache, kmem_cache->object_size);
---
\
 
 \ /
  Last update: 2019-05-15 08:45    [W:0.211 / U:0.008 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site