lkml.org 
[lkml]   [2017]   [Jan]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] slab: add a check for the first kmem_cache not to be destroyed
On Mon, Jan 16, 2017 at 04:04:59PM +0900, Kyunghwan Kwon wrote:
> The first kmem_cache created at booting up is supposed neither mergeable
> nor destroyable but was possible to destroy. So prevent it.
>
> Signed-off-by: Kyunghwan Kwon <kwon@toanyone.net>
> ---
> mm/slab_common.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/mm/slab_common.c b/mm/slab_common.c
> index 1dfc209..2d30ace 100644
> --- a/mm/slab_common.c
> +++ b/mm/slab_common.c
> @@ -744,7 +744,7 @@ void kmem_cache_destroy(struct kmem_cache *s)
> bool need_rcu_barrier = false;
> int err;
>
> - if (unlikely(!s))
> + if (unlikely(!s) || s->refcount == -1)
> return;

Hello, Kyunghwan.

Few lines below, s->refcount is checked.

if (s->refcount)
goto unlock;

Am I missing something?

Thanks.

\
 
 \ /
  Last update: 2017-01-17 02:42    [W:0.064 / U:0.140 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site