public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] proc: add error handling for kmem_cache_create
@ 2018-06-12  4:23 Zhouyang Jia
  2018-06-12  5:09 ` Alexey Dobriyan
  2018-06-12  5:21 ` kbuild test robot
  0 siblings, 2 replies; 3+ messages in thread
From: Zhouyang Jia @ 2018-06-12  4:23 UTC (permalink / raw)
  Cc: Zhouyang Jia, Andrew Morton, Alexey Dobriyan, Al Viro,
	Thomas Gleixner, Greg Kroah-Hartman, linux-kernel

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


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-06-12  5:21 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-06-12  4:23 [PATCH] proc: add error handling for kmem_cache_create Zhouyang Jia
2018-06-12  5:09 ` Alexey Dobriyan
2018-06-12  5:21 ` kbuild test robot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox