Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1224186

Re: [PATCH 12/39] dm: drop null test before destroy functions

From Mikulas Patocka <mpatocka@redhat.com>
Newsgroups linux.kernel
Subject Re: [PATCH 12/39] dm: drop null test before destroy functions
Date 2015-09-14 16:10 +0200
Message-ID <q8CCe-8ro-35@gated-at.bofh.it> (permalink)
References <q8ezT-7xJ-3@gated-at.bofh.it> <q8eJC-7J8-39@gated-at.bofh.it> <q8CiS-7Pp-17@gated-at.bofh.it> <q8CCd-8ro-9@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw



On Mon, 14 Sep 2015, Mike Snitzer wrote:

> On Mon, Sep 14 2015 at  9:46am -0400,
> Mikulas Patocka <mpatocka@redhat.com> wrote:
> 
> > 
> > 
> > On Sun, 13 Sep 2015, Julia Lawall wrote:
> > 
> > > Remove unneeded NULL test.
> > > 
> > > The semantic patch that makes this change is as follows:
> > > (http://coccinelle.lip6.fr/)
> > > 
> > > // <smpl>
> > > @@ expression x; @@
> > > -if (x != NULL)
> > >   \(kmem_cache_destroy\|mempool_destroy\|dma_pool_destroy\)(x);
> > > // </smpl>
> > > 
> > > Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
> > > 
> > > ---
> > >  drivers/md/dm-bufio.c              |    3 +--
> > >  drivers/md/dm-cache-target.c       |    3 +--
> > >  drivers/md/dm-crypt.c              |    6 ++----
> > >  drivers/md/dm-io.c                 |    3 +--
> > >  drivers/md/dm-log-userspace-base.c |    3 +--
> > >  drivers/md/dm-region-hash.c        |    4 +---
> > >  drivers/md/dm.c                    |   13 ++++---------
> > >  7 files changed, 11 insertions(+), 24 deletions(-)
> > > 
> > > diff --git a/drivers/md/dm-bufio.c b/drivers/md/dm-bufio.c
> > > index 83cc52e..8ad39b6 100644
> > > --- a/drivers/md/dm-bufio.c
> > > +++ b/drivers/md/dm-bufio.c
> > > @@ -1864,8 +1864,7 @@ static void __exit dm_bufio_exit(void)
> > >  	for (i = 0; i < ARRAY_SIZE(dm_bufio_caches); i++) {
> > >  		struct kmem_cache *kc = dm_bufio_caches[i];
> > >  
> > > -		if (kc)
> > > -			kmem_cache_destroy(kc);
> > > +		kmem_cache_destroy(kc);
> > >  	}
> > 
> > The variable here can be NULL. I don't know how did you conclude that it 
> > cannot. It seems that you didn't test the patch, if you did, you'd hit 
> > NULL pointer dereference here.
> 
> kmem_cache_destroy(), mempool_destroy(), etc all check for NULL and just
> return.  So there is no need for the callers to check for NULL too.
> 
> Mike

I see. It was recent change that I missed.

Mikulas
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 12/39] dm: drop null test before destroy functions Julia Lawall <Julia.Lawall@lip6.fr> - 2015-09-13 14:40 +0200
  Re: [dm-devel] [PATCH 12/39] dm: drop null test before destroy  functions Mikulas Patocka <mpatocka@redhat.com> - 2015-09-14 15:50 +0200
    Re: [PATCH 12/39] dm: drop null test before destroy functions Mike Snitzer <snitzer@redhat.com> - 2015-09-14 16:10 +0200
      Re: [PATCH 12/39] dm: drop null test before destroy functions Mikulas Patocka <mpatocka@redhat.com> - 2015-09-14 16:10 +0200
        Re: [PATCH 12/39] dm: drop null test before destroy functions Julia Lawall <julia.lawall@lip6.fr> - 2015-09-14 21:00 +0200
    Re: [dm-devel] [PATCH 12/39] dm: drop null test before destroy functions walter harms <wharms@bfs.de> - 2015-09-14 16:30 +0200

csiph-web