lkml.org 
[lkml]   [2015]   [Jun]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] zsmalloc: fix a null pointer dereference in destroy_handle_cache()
On Tue, 9 Jun 2015 09:38:27 +0900 Joonsoo Kim <iamjoonsoo.kim@lge.com> wrote:

> > > ...
> > >
> > > --- a/mm/zsmalloc.c
> > > +++ b/mm/zsmalloc.c
> > > @@ -285,7 +285,8 @@ static int create_handle_cache(struct zs_pool *pool)
> > >
> > > static void destroy_handle_cache(struct zs_pool *pool)
> > > {
> > > - kmem_cache_destroy(pool->handle_cachep);
> > > + if (pool->handle_cachep)
> > > + kmem_cache_destroy(pool->handle_cachep);
> > > }
> > >
> > > static unsigned long alloc_handle(struct zs_pool *pool)
> >
> > I'll apply this, but... from a bit of grepping I'm estimating that we
> > have approximately 200 instances of
> >
> > if (foo)
> > kmem_cache_destroy(foo);
> >
> > so obviously kmem_cache_destroy() should be doing the check.
>
> Hello, Andrew.
>
> I'm not sure if doing the check in kmem_cache_destroy() is better.

Of course it's better - we have *hundreds* of sites doing something
which could be done at a single site. Where's the advantage in that?

> My quick grep for other pool based allocators(ex. mempool, zpool) also
> says that they don't check whether passed pool pointer is NULL or not
> in destroy function.

Maybe some of those should be converted as well.


\
 
 \ /
  Last update: 2015-06-09 03:01    [W:0.067 / U:2.952 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site