lkml.org 
[lkml]   [2018]   [Jun]   [12]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] proc: add error handling for kmem_cache_create
Date
When kmem_cache_create fails, the lack of error-handling code may
cause unexpected results.

This patch adds error-handling code after calling kmem_cache_create.

Signed-off-by: Zhouyang Jia <jiazhouyang09@gmail.com>
---
fs/proc/inode.c | 3 +++
1 file changed, 3 insertions(+)

diff --git a/fs/proc/inode.c b/fs/proc/inode.c
index 2cf3b74..5d8b2d1 100644
--- a/fs/proc/inode.c
+++ b/fs/proc/inode.c
@@ -104,6 +104,9 @@ void __init proc_init_kmemcache(void)
pde_opener_cache =
kmem_cache_create("pde_opener", sizeof(struct pde_opener), 0,
SLAB_ACCOUNT|SLAB_PANIC, NULL);
+ if (!proc_inode_cachep || !pde_opener_cache)
+ return -ENOMEM;
+
proc_dir_entry_cache = kmem_cache_create_usercopy(
"proc_dir_entry", sizeof(struct proc_dir_entry), 0, SLAB_PANIC,
offsetof(struct proc_dir_entry, inline_name),
--
2.7.4
\
 
 \ /
  Last update: 2018-06-12 06:24    [W:0.040 / U:0.792 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site