inotify: add error handling for kmem_cache_create
Subsystems (3)
PATCH 1/1 inotify: add error handling for kmem_cache_create
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.
--- fs/notify/inotify/inotify_user.c | 2 ++ 1 file changed, 2 insertions(+)
fs/notify/inotify/inotify_user.c +2 -0
@@ -805,6 +805,8 @@ static int __init inotify_user_setup(void)BUG_ON (hweight32 (ALL_INOTIFY_BITS ) !=21 ); inotify_inode_mark_cachep =KMEM_CACHE (inotify_inode_mark,SLAB_PANIC ); +if (!inotify_inode_mark_cachep) +return -ENOMEM ; inotify_max_queued_events =16384 ; init_user_ns.ucount_max[UCOUNT_INOTIFY_INSTANCES ] =128 ;
Signature · 1 line
2.7.4
Quoted 7 lines
锟斤拷 2018锟斤拷6锟斤拷12锟秸o拷锟斤拷锟斤拷12:22锟斤拷Zhouyang Jia <[email protected]> 写锟斤拷锟斤拷
When
kmem_cache_createfails, the lack of error-handling code may cause unexpected results.This patch adds error-handling code after calling
kmem_cache_create.
I think SLAB_PANIC can handle this case.
Thanks,
Chengguang.
Quoted 22 lines
Signed-off-by Zhouyang Jia <[email protected]>---
fs/notify/inotify/inotify_user.c| 2 ++1 file changed, 2 insertions(+)fs/notify/inotify/inotify_user.c +2
-0@@ -805,6 +805,8 @@ static int __init inotify_user_setup(void)BUG_ON (hweight32 (ALL_INOTIFY_BITS ) !=21 ); inotify_inode_mark_cachep =KMEM_CACHE (inotify_inode_mark,SLAB_PANIC ); +if (!inotify_inode_mark_cachep) +return -ENOMEM ; inotify_max_queued_events =16384 ; init_user_ns.ucount_max[UCOUNT_INOTIFY_INSTANCES ] =128 ;Signature · 1 line
2.7.4
in __kmem_cache_create->kmem_cache_open
with SLAB_PANIC, kernel will panic if it fail
Quoted 36 lines · On Tue, Jun 12, 2018 at 3:41 PM, [email protected] <[email protected]> wrote:
Quoted 7 lines · 在 2018年6月12日,下午12:22,Zhouyang Jia <[email protected]> 写道:
When
kmem_cache_createfails, the lack of error-handling code may cause unexpected results.This patch adds error-handling code after calling
kmem_cache_create.I think
SLAB_PANICcan handle this case.Thanks,
Chengguang.Quoted 22 lines
Signed-off-by Zhouyang Jia <[email protected]>---
fs/notify/inotify/inotify_user.c| 2 ++1 file changed, 2 insertions(+)fs/notify/inotify/inotify_user.c +2
-1@@ -805,6 +805,8 @@ static int __init inotify_user_setup(void)BUG_ON (hweight32 (ALL_INOTIFY_BITS ) !=21 ); inotify_inode_mark_cachep =KMEM_CACHE (inotify_inode_mark,SLAB_PANIC ); +if (!inotify_inode_mark_cachep) +return -ENOMEM ; inotify_max_queued_events =16384 ; init_user_ns.ucount_max[UCOUNT_INOTIFY_INSTANCES ] =128 ; --2.7.4
Signature · 2 lines
Best regards Kassey