Messages in this thread Patch in this message | | | From | Zhouyang Jia <> | Subject | [PATCH] proc: add error handling for kmem_cache_create | Date | Tue, 12 Jun 2018 12:23:52 +0800 |
| |
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
| |