linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] inotify: add error handling for kmem_cache_create
@ 2018-06-12  4:22 Zhouyang Jia
  2018-06-12  7:41 ` cgxu519
  0 siblings, 1 reply; 3+ messages in thread
From: Zhouyang Jia @ 2018-06-12  4:22 UTC (permalink / raw)
  Cc: Zhouyang Jia, Jan Kara, Amir Goldstein, linux-fsdevel, 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/notify/inotify/inotify_user.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/fs/notify/inotify/inotify_user.c b/fs/notify/inotify/inotify_user.c
index ef32f36..0704bab 100644
--- a/fs/notify/inotify/inotify_user.c
+++ b/fs/notify/inotify/inotify_user.c
@@ -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

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

* Re: [PATCH] inotify: add error handling for kmem_cache_create
  2018-06-12  4:22 [PATCH] inotify: add error handling for kmem_cache_create Zhouyang Jia
@ 2018-06-12  7:41 ` cgxu519
  2018-06-12  9:53   ` Kassey
  0 siblings, 1 reply; 3+ messages in thread
From: cgxu519 @ 2018-06-12  7:41 UTC (permalink / raw)
  To: Zhouyang Jia
  Cc: cgxu519, Jan Kara, Amir Goldstein, linux-fsdevel, linux-kernel


> 锟斤拷 2018锟斤拷6锟斤拷12锟秸o拷锟斤拷锟斤拷12:22锟斤拷Zhouyang Jia <jiazhouyang09@gmail.com> 写锟斤拷锟斤拷
> 
> 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.

I think SLAB_PANIC can handle this case.

Thanks,
Chengguang.

> 
> Signed-off-by: Zhouyang Jia <jiazhouyang09@gmail.com>
> ---
> fs/notify/inotify/inotify_user.c | 2 ++
> 1 file changed, 2 insertions(+)
> 
> diff --git a/fs/notify/inotify/inotify_user.c b/fs/notify/inotify/inotify_user.c
> index ef32f36..0704bab 100644
> --- a/fs/notify/inotify/inotify_user.c
> +++ b/fs/notify/inotify/inotify_user.c
> @@ -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
> 

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

* Re: [PATCH] inotify: add error handling for kmem_cache_create
  2018-06-12  7:41 ` cgxu519
@ 2018-06-12  9:53   ` Kassey
  0 siblings, 0 replies; 3+ messages in thread
From: Kassey @ 2018-06-12  9:53 UTC (permalink / raw)
  To: cgxu519
  Cc: Zhouyang Jia, Jan Kara, Amir Goldstein, linux-fsdevel, linux-kernel

in __kmem_cache_create->kmem_cache_open

with SLAB_PANIC, kernel will panic if it fail

On Tue, Jun 12, 2018 at 3:41 PM, cgxu519@gmx.com <cgxu519@gmx.com> wrote:
>
>> 在 2018年6月12日,下午12:22,Zhouyang Jia <jiazhouyang09@gmail.com> 写道:
>>
>> 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.
>
> I think SLAB_PANIC can handle this case.
>
> Thanks,
> Chengguang.
>
>>
>> Signed-off-by: Zhouyang Jia <jiazhouyang09@gmail.com>
>> ---
>> fs/notify/inotify/inotify_user.c | 2 ++
>> 1 file changed, 2 insertions(+)
>>
>> diff --git a/fs/notify/inotify/inotify_user.c b/fs/notify/inotify/inotify_user.c
>> index ef32f36..0704bab 100644
>> --- a/fs/notify/inotify/inotify_user.c
>> +++ b/fs/notify/inotify/inotify_user.c
>> @@ -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
>>
>



-- 
Best regards
Kassey

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

end of thread, other threads:[~2018-06-12  9:53 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:22 [PATCH] inotify: add error handling for kmem_cache_create Zhouyang Jia
2018-06-12  7:41 ` cgxu519
2018-06-12  9:53   ` Kassey

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).