linux-raid.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 00/39] drop null test before destroy functions
@ 2015-09-13 12:14 Julia Lawall
  2015-09-13 12:15 ` [PATCH 12/39] dm: " Julia Lawall
                   ` (3 more replies)
  0 siblings, 4 replies; 12+ messages in thread
From: Julia Lawall @ 2015-09-13 12:14 UTC (permalink / raw)
  To: iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA,
	dccp-u79uwXL29TY76Z2rM5mHXA,
	dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW,
	intel-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW,
	ecryptfs-u79uwXL29TY76Z2rM5mHXA, dmaengine-u79uwXL29TY76Z2rM5mHXA
  Cc: linux-usb-u79uwXL29TY76Z2rM5mHXA, kvm-u79uwXL29TY76Z2rM5mHXA,
	kernel-janitors-u79uwXL29TY76Z2rM5mHXA,
	HPDD-discuss-hn68Rpc1hR1g9hUCZPvPmw,
	linux-mtd-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	ocfs2-devel-N0ozoZBvEnrZJqsBc5GL+g, Carolyn Wyborny,
	ceph-devel-u79uwXL29TY76Z2rM5mHXA,
	devel-gWbeCf7V1WCQmaza687I9mD2FQJk+8+b,
	linux-nilfs-u79uwXL29TY76Z2rM5mHXA,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA, Don Skidmore,
	linux-atm-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f,
	Jesse Brandeburg, cluster-devel-H+wXaHxf7aLQT0dZR+AlfA,
	Matthew Vick, intel-wired-lan-qjLDD68F18P21nG7glBr7A,
	linux-ext4-u79uwXL29TY76Z2rM5mHXA, Mitch Williams, Chao Yu,
	linux-raid-u79uwXL29TY76Z2rM5mHXA,
	linux-bcache-u79uwXL29TY76Z2rM5mHXA, Dan Williams,
	linux-nfs-u79uwXL29TY76Z2rM5mHXA, netdev-u79uwXL29TY76Z2rM5mHXA,
	Shannon Nelson, linux-kernel-u79uwXL29TaqPxH82wqD4g

Recent commits to kernel/git/torvalds/linux.git have made the following
functions able to tolerate NULL arguments:

kmem_cache_destroy (commit 3942d29918522)
mempool_destroy (commit 4e3ca3e033d1)
dma_pool_destroy (commit 44d7175da6ea)

These patches remove the associated NULL tests for the files that I found
easy to compile test.  If these changes are OK, I will address the
remainder later.

---

 arch/x86/kvm/mmu.c                                 |    6 --
 block/bio-integrity.c                              |    7 --
 block/bio.c                                        |    7 --
 block/blk-core.c                                   |    3 -
 block/elevator.c                                   |    3 -
 drivers/atm/he.c                                   |    7 --
 drivers/block/aoe/aoedev.c                         |    3 -
 drivers/block/drbd/drbd_main.c                     |   21 ++-----
 drivers/block/pktcdvd.c                            |    3 -
 drivers/block/rbd.c                                |    6 --
 drivers/dma/dmaengine.c                            |    6 --
 drivers/firmware/google/gsmi.c                     |    3 -
 drivers/gpu/drm/i915/i915_dma.c                    |   19 ++----
 drivers/iommu/amd_iommu_init.c                     |    7 --
 drivers/md/bcache/bset.c                           |    3 -
 drivers/md/bcache/request.c                        |    3 -
 drivers/md/bcache/super.c                          |    9 +--
 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 +---
 drivers/md/multipath.c                             |    3 -
 drivers/md/raid1.c                                 |    6 --
 drivers/md/raid10.c                                |    9 +--
 drivers/md/raid5.c                                 |    3 -
 drivers/mtd/nand/nandsim.c                         |    3 -
 drivers/mtd/ubi/attach.c                           |    4 -
 drivers/net/ethernet/intel/ixgbe/ixgbe_fcoe.c      |    3 -
 drivers/staging/lustre/lustre/llite/super25.c      |   16 +----
 drivers/staging/lustre/lustre/obdclass/genops.c    |   24 ++------
 drivers/staging/lustre/lustre/obdclass/lu_object.c |    6 --
 drivers/staging/rdma/hfi1/user_sdma.c              |    3 -
 drivers/thunderbolt/ctl.c                          |    3 -
 drivers/usb/gadget/udc/bdc/bdc_core.c              |    3 -
 drivers/usb/gadget/udc/gr_udc.c                    |    3 -
 drivers/usb/gadget/udc/mv_u3d_core.c               |    3 -
 drivers/usb/gadget/udc/mv_udc_core.c               |    3 -
 drivers/usb/host/fotg210-hcd.c                     |   12 +---
 drivers/usb/host/fusbh200-hcd.c                    |   12 +---
 drivers/usb/host/whci/init.c                       |    3 -
 drivers/usb/host/xhci-mem.c                        |   12 +---
 fs/btrfs/backref.c                                 |    3 -
 fs/btrfs/delayed-inode.c                           |    3 -
 fs/btrfs/delayed-ref.c                             |   12 +---
 fs/btrfs/disk-io.c                                 |    3 -
 fs/btrfs/extent_io.c                               |    6 --
 fs/btrfs/extent_map.c                              |    3 -
 fs/btrfs/file.c                                    |    3 -
 fs/btrfs/inode.c                                   |   18 ++----
 fs/btrfs/ordered-data.c                            |    3 -
 fs/dlm/memory.c                                    |    6 --
 fs/ecryptfs/main.c                                 |    3 -
 fs/ext4/crypto.c                                   |    9 +--
 fs/ext4/extents_status.c                           |    3 -
 fs/ext4/mballoc.c                                  |    3 -
 fs/f2fs/crypto.c                                   |    9 +--
 fs/gfs2/main.c                                     |   29 ++--------
 fs/jbd2/journal.c                                  |   15 +----
 fs/jbd2/revoke.c                                   |   12 +---
 fs/jbd2/transaction.c                              |    6 --
 fs/jffs2/malloc.c                                  |   27 +++------
 fs/nfsd/nfscache.c                                 |    6 --
 fs/nilfs2/super.c                                  |   12 +---
 fs/ocfs2/dlm/dlmlock.c                             |    3 -
 fs/ocfs2/dlm/dlmmaster.c                           |   16 +----
 fs/ocfs2/super.c                                   |   18 ++----
 fs/ocfs2/uptodate.c                                |    3 -
 lib/debugobjects.c                                 |    3 -
 net/core/sock.c                                    |   12 +---
 net/dccp/ackvec.c                                  |   12 +---
 net/dccp/ccid.c                                    |    3 -
 net/sunrpc/sched.c                                 |   12 +---
 75 files changed, 180 insertions(+), 381 deletions(-)

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

* [PATCH 12/39] dm: drop null test before destroy functions
  2015-09-13 12:14 [PATCH 00/39] drop null test before destroy functions Julia Lawall
@ 2015-09-13 12:15 ` Julia Lawall
  2015-09-14 13:46   ` [dm-devel] " Mikulas Patocka
  2015-09-13 12:15 ` [PATCH 15/39] bcache: " Julia Lawall
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 12+ messages in thread
From: Julia Lawall @ 2015-09-13 12:15 UTC (permalink / raw)
  To: Alasdair Kergon
  Cc: sergey.senozhatsky, kernel-janitors, Mike Snitzer, dm-devel,
	Neil Brown, linux-raid, linux-kernel

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);
 	}
 
 	for (i = 0; i < ARRAY_SIZE(dm_bufio_cache_names); i++)
diff --git a/drivers/md/dm.c b/drivers/md/dm.c
index 6264781..163de31 100644
--- a/drivers/md/dm.c
+++ b/drivers/md/dm.c
@@ -2220,10 +2220,8 @@ static void cleanup_mapped_device(struct mapped_device *md)
 		destroy_workqueue(md->wq);
 	if (md->kworker_task)
 		kthread_stop(md->kworker_task);
-	if (md->io_pool)
-		mempool_destroy(md->io_pool);
-	if (md->rq_pool)
-		mempool_destroy(md->rq_pool);
+	mempool_destroy(md->io_pool);
+	mempool_destroy(md->rq_pool);
 	if (md->bs)
 		bioset_free(md->bs);
 
@@ -3508,11 +3506,8 @@ void dm_free_md_mempools(struct dm_md_mempools *pools)
 	if (!pools)
 		return;
 
-	if (pools->io_pool)
-		mempool_destroy(pools->io_pool);
-
-	if (pools->rq_pool)
-		mempool_destroy(pools->rq_pool);
+	mempool_destroy(pools->io_pool);
+	mempool_destroy(pools->rq_pool);
 
 	if (pools->bs)
 		bioset_free(pools->bs);
diff --git a/drivers/md/dm-log-userspace-base.c b/drivers/md/dm-log-userspace-base.c
index 058256d..53b7b06 100644
--- a/drivers/md/dm-log-userspace-base.c
+++ b/drivers/md/dm-log-userspace-base.c
@@ -313,8 +313,7 @@ static int userspace_ctr(struct dm_dirty_log *log, struct dm_target *ti,
 out:
 	kfree(devices_rdata);
 	if (r) {
-		if (lc->flush_entry_pool)
-			mempool_destroy(lc->flush_entry_pool);
+		mempool_destroy(lc->flush_entry_pool);
 		kfree(lc);
 		kfree(ctr_str);
 	} else {
diff --git a/drivers/md/dm-io.c b/drivers/md/dm-io.c
index 6f8e83b..81c5e1a 100644
--- a/drivers/md/dm-io.c
+++ b/drivers/md/dm-io.c
@@ -65,8 +65,7 @@ struct dm_io_client *dm_io_client_create(void)
 	return client;
 
    bad:
-	if (client->pool)
-		mempool_destroy(client->pool);
+	mempool_destroy(client->pool);
 	kfree(client);
 	return ERR_PTR(-ENOMEM);
 }
diff --git a/drivers/md/dm-cache-target.c b/drivers/md/dm-cache-target.c
index dd90d12..2fd4c82 100644
--- a/drivers/md/dm-cache-target.c
+++ b/drivers/md/dm-cache-target.c
@@ -2309,8 +2309,7 @@ static void destroy(struct cache *cache)
 {
 	unsigned i;
 
-	if (cache->migration_pool)
-		mempool_destroy(cache->migration_pool);
+	mempool_destroy(cache->migration_pool);
 
 	if (cache->all_io_ds)
 		dm_deferred_set_destroy(cache->all_io_ds);
diff --git a/drivers/md/dm-crypt.c b/drivers/md/dm-crypt.c
index d60c88d..cf91a96 100644
--- a/drivers/md/dm-crypt.c
+++ b/drivers/md/dm-crypt.c
@@ -1543,10 +1543,8 @@ static void crypt_dtr(struct dm_target *ti)
 	if (cc->bs)
 		bioset_free(cc->bs);
 
-	if (cc->page_pool)
-		mempool_destroy(cc->page_pool);
-	if (cc->req_pool)
-		mempool_destroy(cc->req_pool);
+	mempool_destroy(cc->page_pool);
+	mempool_destroy(cc->req_pool);
 
 	if (cc->iv_gen_ops && cc->iv_gen_ops->dtr)
 		cc->iv_gen_ops->dtr(cc);
diff --git a/drivers/md/dm-region-hash.c b/drivers/md/dm-region-hash.c
index b929fd5..f3d608b 100644
--- a/drivers/md/dm-region-hash.c
+++ b/drivers/md/dm-region-hash.c
@@ -249,9 +249,7 @@ void dm_region_hash_destroy(struct dm_region_hash *rh)
 	if (rh->log)
 		dm_dirty_log_destroy(rh->log);
 
-	if (rh->region_pool)
-		mempool_destroy(rh->region_pool);
-
+	mempool_destroy(rh->region_pool);
 	vfree(rh->buckets);
 	kfree(rh);
 }

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

* [PATCH 15/39] bcache: drop null test before destroy functions
  2015-09-13 12:14 [PATCH 00/39] drop null test before destroy functions Julia Lawall
  2015-09-13 12:15 ` [PATCH 12/39] dm: " Julia Lawall
@ 2015-09-13 12:15 ` Julia Lawall
  2015-09-14  9:08   ` Johannes Thumshirn
  2015-09-13 12:15 ` [PATCH 17/39] md: " Julia Lawall
  2015-09-14 11:55 ` [PATCH 00/39] " SF Markus Elfring
  3 siblings, 1 reply; 12+ messages in thread
From: Julia Lawall @ 2015-09-13 12:15 UTC (permalink / raw)
  To: Kent Overstreet
  Cc: sergey.senozhatsky, kernel-janitors, Neil Brown, linux-bcache,
	linux-raid, linux-kernel

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/bcache/bset.c    |    3 +--
 drivers/md/bcache/request.c |    3 +--
 drivers/md/bcache/super.c   |    9 +++------
 3 files changed, 5 insertions(+), 10 deletions(-)

diff --git a/drivers/md/bcache/request.c b/drivers/md/bcache/request.c
index 8e9877b..bd4678c 100644
--- a/drivers/md/bcache/request.c
+++ b/drivers/md/bcache/request.c
@@ -1145,8 +1145,7 @@ void bch_flash_dev_request_init(struct bcache_device *d)
 
 void bch_request_exit(void)
 {
-	if (bch_search_cache)
-		kmem_cache_destroy(bch_search_cache);
+	kmem_cache_destroy(bch_search_cache);
 }
 
 int __init bch_request_init(void)
diff --git a/drivers/md/bcache/bset.c b/drivers/md/bcache/bset.c
index 646fe85..479117c 100644
--- a/drivers/md/bcache/bset.c
+++ b/drivers/md/bcache/bset.c
@@ -1116,8 +1116,7 @@ struct bkey *bch_btree_iter_next_filter(struct btree_iter *iter,
 
 void bch_bset_sort_state_free(struct bset_sort_state *state)
 {
-	if (state->pool)
-		mempool_destroy(state->pool);
+	mempool_destroy(state->pool);
 }
 
 int bch_bset_sort_state_init(struct bset_sort_state *state, unsigned page_order)
diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c
index 679a093..c27a0ff 100644
--- a/drivers/md/bcache/super.c
+++ b/drivers/md/bcache/super.c
@@ -1335,12 +1335,9 @@ static void cache_set_free(struct closure *cl)
 		destroy_workqueue(c->moving_gc_wq);
 	if (c->bio_split)
 		bioset_free(c->bio_split);
-	if (c->fill_iter)
-		mempool_destroy(c->fill_iter);
-	if (c->bio_meta)
-		mempool_destroy(c->bio_meta);
-	if (c->search)
-		mempool_destroy(c->search);
+	mempool_destroy(c->fill_iter);
+	mempool_destroy(c->bio_meta);
+	mempool_destroy(c->search);
 	kfree(c->devices);
 
 	mutex_lock(&bch_register_lock);

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

* [PATCH 17/39] md: drop null test before destroy functions
  2015-09-13 12:14 [PATCH 00/39] drop null test before destroy functions Julia Lawall
  2015-09-13 12:15 ` [PATCH 12/39] dm: " Julia Lawall
  2015-09-13 12:15 ` [PATCH 15/39] bcache: " Julia Lawall
@ 2015-09-13 12:15 ` Julia Lawall
  2015-09-15  7:29   ` Neil Brown
  2015-09-14 11:55 ` [PATCH 00/39] " SF Markus Elfring
  3 siblings, 1 reply; 12+ messages in thread
From: Julia Lawall @ 2015-09-13 12:15 UTC (permalink / raw)
  To: Neil Brown; +Cc: sergey.senozhatsky, kernel-janitors, linux-raid, linux-kernel

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/multipath.c |    3 +--
 drivers/md/raid1.c     |    6 ++----
 drivers/md/raid10.c    |    9 +++------
 drivers/md/raid5.c     |    3 +--
 4 files changed, 7 insertions(+), 14 deletions(-)

diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index 15ef2c6..09a12d7 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -2271,8 +2271,7 @@ static void shrink_stripes(struct r5conf *conf)
 	       drop_one_stripe(conf))
 		;
 
-	if (conf->slab_cache)
-		kmem_cache_destroy(conf->slab_cache);
+	kmem_cache_destroy(conf->slab_cache);
 	conf->slab_cache = NULL;
 }
 
diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
index 4517f06..5f4f553 100644
--- a/drivers/md/raid1.c
+++ b/drivers/md/raid1.c
@@ -2843,8 +2843,7 @@ static struct r1conf *setup_conf(struct mddev *mddev)
 
  abort:
 	if (conf) {
-		if (conf->r1bio_pool)
-			mempool_destroy(conf->r1bio_pool);
+		mempool_destroy(conf->r1bio_pool);
 		kfree(conf->mirrors);
 		safe_put_page(conf->tmppage);
 		kfree(conf->poolinfo);
@@ -2946,8 +2945,7 @@ static void raid1_free(struct mddev *mddev, void *priv)
 {
 	struct r1conf *conf = priv;
 
-	if (conf->r1bio_pool)
-		mempool_destroy(conf->r1bio_pool);
+	mempool_destroy(conf->r1bio_pool);
 	kfree(conf->mirrors);
 	safe_put_page(conf->tmppage);
 	kfree(conf->poolinfo);
diff --git a/drivers/md/multipath.c b/drivers/md/multipath.c
index d222522..d132f06 100644
--- a/drivers/md/multipath.c
+++ b/drivers/md/multipath.c
@@ -470,8 +470,7 @@ static int multipath_run (struct mddev *mddev)
 	return 0;
 
 out_free_conf:
-	if (conf->pool)
-		mempool_destroy(conf->pool);
+	mempool_destroy(conf->pool);
 	kfree(conf->multipaths);
 	kfree(conf);
 	mddev->private = NULL;
diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
index 0fc33eb..7c99a40 100644
--- a/drivers/md/raid10.c
+++ b/drivers/md/raid10.c
@@ -3486,8 +3486,7 @@ static struct r10conf *setup_conf(struct mddev *mddev)
 		printk(KERN_ERR "md/raid10:%s: couldn't allocate memory.\n",
 		       mdname(mddev));
 	if (conf) {
-		if (conf->r10bio_pool)
-			mempool_destroy(conf->r10bio_pool);
+		mempool_destroy(conf->r10bio_pool);
 		kfree(conf->mirrors);
 		safe_put_page(conf->tmppage);
 		kfree(conf);
@@ -3682,8 +3681,7 @@ static int run(struct mddev *mddev)
 
 out_free_conf:
 	md_unregister_thread(&mddev->thread);
-	if (conf->r10bio_pool)
-		mempool_destroy(conf->r10bio_pool);
+	mempool_destroy(conf->r10bio_pool);
 	safe_put_page(conf->tmppage);
 	kfree(conf->mirrors);
 	kfree(conf);
@@ -3696,8 +3694,7 @@ static void raid10_free(struct mddev *mddev, void *priv)
 {
 	struct r10conf *conf = priv;
 
-	if (conf->r10bio_pool)
-		mempool_destroy(conf->r10bio_pool);
+	mempool_destroy(conf->r10bio_pool);
 	safe_put_page(conf->tmppage);
 	kfree(conf->mirrors);
 	kfree(conf->mirrors_old);

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

* Re: [PATCH 15/39] bcache: drop null test before destroy functions
  2015-09-13 12:15 ` [PATCH 15/39] bcache: " Julia Lawall
@ 2015-09-14  9:08   ` Johannes Thumshirn
  0 siblings, 0 replies; 12+ messages in thread
From: Johannes Thumshirn @ 2015-09-14  9:08 UTC (permalink / raw)
  To: Julia Lawall
  Cc: Kent Overstreet, sergey.senozhatsky, kernel-janitors, Neil Brown,
	linux-bcache, linux-raid, linux-kernel

Julia Lawall <Julia.Lawall@lip6.fr> writes:

> 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>

Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>

>
> ---
>  drivers/md/bcache/bset.c    |    3 +--
>  drivers/md/bcache/request.c |    3 +--
>  drivers/md/bcache/super.c   |    9 +++------
>  3 files changed, 5 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/md/bcache/request.c b/drivers/md/bcache/request.c
> index 8e9877b..bd4678c 100644
> --- a/drivers/md/bcache/request.c
> +++ b/drivers/md/bcache/request.c
> @@ -1145,8 +1145,7 @@ void bch_flash_dev_request_init(struct bcache_device *d)
>  
>  void bch_request_exit(void)
>  {
> -	if (bch_search_cache)
> -		kmem_cache_destroy(bch_search_cache);
> +	kmem_cache_destroy(bch_search_cache);
>  }
>  
>  int __init bch_request_init(void)
> diff --git a/drivers/md/bcache/bset.c b/drivers/md/bcache/bset.c
> index 646fe85..479117c 100644
> --- a/drivers/md/bcache/bset.c
> +++ b/drivers/md/bcache/bset.c
> @@ -1116,8 +1116,7 @@ struct bkey *bch_btree_iter_next_filter(struct btree_iter *iter,
>  
>  void bch_bset_sort_state_free(struct bset_sort_state *state)
>  {
> -	if (state->pool)
> -		mempool_destroy(state->pool);
> +	mempool_destroy(state->pool);
>  }
>  
>  int bch_bset_sort_state_init(struct bset_sort_state *state, unsigned page_order)
> diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c
> index 679a093..c27a0ff 100644
> --- a/drivers/md/bcache/super.c
> +++ b/drivers/md/bcache/super.c
> @@ -1335,12 +1335,9 @@ static void cache_set_free(struct closure *cl)
>  		destroy_workqueue(c->moving_gc_wq);
>  	if (c->bio_split)
>  		bioset_free(c->bio_split);
> -	if (c->fill_iter)
> -		mempool_destroy(c->fill_iter);
> -	if (c->bio_meta)
> -		mempool_destroy(c->bio_meta);
> -	if (c->search)
> -		mempool_destroy(c->search);
> +	mempool_destroy(c->fill_iter);
> +	mempool_destroy(c->bio_meta);
> +	mempool_destroy(c->search);
>  	kfree(c->devices);
>  
>  	mutex_lock(&bch_register_lock);
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-bcache" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

-- 
Johannes Thumshirn                                           Storage
jthumshirn@suse.de                                 +49 911 74053 689
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: Felix Imendörffer, Jane Smithard, Graham Norton
HRB 21284 (AG Nürnberg)
Key fingerprint = EC38 9CAB C2C4 F25D 8600  D0D0 0393 969D 2D76 0850

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

* Re: [PATCH 00/39] drop null test before destroy functions
  2015-09-13 12:14 [PATCH 00/39] drop null test before destroy functions Julia Lawall
                   ` (2 preceding siblings ...)
  2015-09-13 12:15 ` [PATCH 17/39] md: " Julia Lawall
@ 2015-09-14 11:55 ` SF Markus Elfring
  3 siblings, 0 replies; 12+ messages in thread
From: SF Markus Elfring @ 2015-09-14 11:55 UTC (permalink / raw)
  To: Julia Lawall, kernel-janitors
  Cc: iommu, dccp, dri-devel, intel-gfx, ecryptfs, dmaengine,
	sergey.senozhatsky, Dan Williams, cluster-devel, intel-wired-lan,
	Mitch Williams, John Ronciak, Matthew Vick, Don Skidmore,
	Carolyn Wyborny, Shannon Nelson, Jesse Brandeburg, linux-nfs,
	linux-raid, netdev, linux-atm-general, linux-btrfs, linux-nilfs,
	linux-kernel, linux-mtd, linux-usb

> Recent commits to kernel/git/torvalds/linux.git have made the following
> functions able to tolerate NULL arguments:
>
> kmem_cache_destroy (commit 3942d29918522)
> mempool_destroy (commit 4e3ca3e033d1)
> dma_pool_destroy (commit 44d7175da6ea)

How do you think about to extend an other SmPL script?

Related topic:
scripts/coccinelle/free: Delete NULL test before freeing functions
https://systeme.lip6.fr/pipermail/cocci/2015-May/001960.html
https://www.mail-archive.com/cocci@systeme.lip6.fr/msg01855.html


> If these changes are OK, I will address the remainder later.

Would anybody like to reuse my general SmPL approach for similar source
code clean-up?

Regards,
Markus

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

* Re: [dm-devel] [PATCH 12/39] dm: drop null test before destroy functions
  2015-09-13 12:15 ` [PATCH 12/39] dm: " Julia Lawall
@ 2015-09-14 13:46   ` Mikulas Patocka
  2015-09-14 14:00     ` Mike Snitzer
  2015-09-14 14:23     ` [dm-devel] " walter harms
  0 siblings, 2 replies; 12+ messages in thread
From: Mikulas Patocka @ 2015-09-14 13:46 UTC (permalink / raw)
  To: device-mapper development
  Cc: Alasdair Kergon, Mike Snitzer, kernel-janitors, Neil Brown,
	linux-kernel, linux-raid, sergey.senozhatsky



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.

>  	for (i = 0; i < ARRAY_SIZE(dm_bufio_cache_names); i++)
> diff --git a/drivers/md/dm.c b/drivers/md/dm.c
> index 6264781..163de31 100644
> --- a/drivers/md/dm.c
> +++ b/drivers/md/dm.c
> @@ -2220,10 +2220,8 @@ static void cleanup_mapped_device(struct mapped_device *md)
>  		destroy_workqueue(md->wq);
>  	if (md->kworker_task)
>  		kthread_stop(md->kworker_task);
> -	if (md->io_pool)
> -		mempool_destroy(md->io_pool);
> -	if (md->rq_pool)
> -		mempool_destroy(md->rq_pool);
> +	mempool_destroy(md->io_pool);
> +	mempool_destroy(md->rq_pool);

Likewise, these variables can be NULL.

>  	if (md->bs)
>  		bioset_free(md->bs);
>  
> @@ -3508,11 +3506,8 @@ void dm_free_md_mempools(struct dm_md_mempools *pools)
>  	if (!pools)
>  		return;
>  
> -	if (pools->io_pool)
> -		mempool_destroy(pools->io_pool);
> -
> -	if (pools->rq_pool)
> -		mempool_destroy(pools->rq_pool);
> +	mempool_destroy(pools->io_pool);
> +	mempool_destroy(pools->rq_pool);
>  
>  	if (pools->bs)
>  		bioset_free(pools->bs);

Likewise, it can be NULL, see for example this code path:
                pools->io_pool = mempool_create_slab_pool(pool_size, cachep);
                if (!pools->io_pool)
                        goto out;
out:
        dm_free_md_mempools(pools);
dm_free_md_mempools:
        if (pools->io_pool)
                mempool_destroy(pools->io_pool);

It seems that you set up the cocinelle tool incorrectly, so that it 
produces many bogus suggestions.

Mikulas

> diff --git a/drivers/md/dm-log-userspace-base.c b/drivers/md/dm-log-userspace-base.c
> index 058256d..53b7b06 100644
> --- a/drivers/md/dm-log-userspace-base.c
> +++ b/drivers/md/dm-log-userspace-base.c
> @@ -313,8 +313,7 @@ static int userspace_ctr(struct dm_dirty_log *log, struct dm_target *ti,
>  out:
>  	kfree(devices_rdata);
>  	if (r) {
> -		if (lc->flush_entry_pool)
> -			mempool_destroy(lc->flush_entry_pool);
> +		mempool_destroy(lc->flush_entry_pool);
>  		kfree(lc);
>  		kfree(ctr_str);
>  	} else {
> diff --git a/drivers/md/dm-io.c b/drivers/md/dm-io.c
> index 6f8e83b..81c5e1a 100644
> --- a/drivers/md/dm-io.c
> +++ b/drivers/md/dm-io.c
> @@ -65,8 +65,7 @@ struct dm_io_client *dm_io_client_create(void)
>  	return client;
>  
>     bad:
> -	if (client->pool)
> -		mempool_destroy(client->pool);
> +	mempool_destroy(client->pool);
>  	kfree(client);
>  	return ERR_PTR(-ENOMEM);
>  }
> diff --git a/drivers/md/dm-cache-target.c b/drivers/md/dm-cache-target.c
> index dd90d12..2fd4c82 100644
> --- a/drivers/md/dm-cache-target.c
> +++ b/drivers/md/dm-cache-target.c
> @@ -2309,8 +2309,7 @@ static void destroy(struct cache *cache)
>  {
>  	unsigned i;
>  
> -	if (cache->migration_pool)
> -		mempool_destroy(cache->migration_pool);
> +	mempool_destroy(cache->migration_pool);
>  
>  	if (cache->all_io_ds)
>  		dm_deferred_set_destroy(cache->all_io_ds);
> diff --git a/drivers/md/dm-crypt.c b/drivers/md/dm-crypt.c
> index d60c88d..cf91a96 100644
> --- a/drivers/md/dm-crypt.c
> +++ b/drivers/md/dm-crypt.c
> @@ -1543,10 +1543,8 @@ static void crypt_dtr(struct dm_target *ti)
>  	if (cc->bs)
>  		bioset_free(cc->bs);
>  
> -	if (cc->page_pool)
> -		mempool_destroy(cc->page_pool);
> -	if (cc->req_pool)
> -		mempool_destroy(cc->req_pool);
> +	mempool_destroy(cc->page_pool);
> +	mempool_destroy(cc->req_pool);
>  
>  	if (cc->iv_gen_ops && cc->iv_gen_ops->dtr)
>  		cc->iv_gen_ops->dtr(cc);
> diff --git a/drivers/md/dm-region-hash.c b/drivers/md/dm-region-hash.c
> index b929fd5..f3d608b 100644
> --- a/drivers/md/dm-region-hash.c
> +++ b/drivers/md/dm-region-hash.c
> @@ -249,9 +249,7 @@ void dm_region_hash_destroy(struct dm_region_hash *rh)
>  	if (rh->log)
>  		dm_dirty_log_destroy(rh->log);
>  
> -	if (rh->region_pool)
> -		mempool_destroy(rh->region_pool);
> -
> +	mempool_destroy(rh->region_pool);
>  	vfree(rh->buckets);
>  	kfree(rh);
>  }
> 
> --
> dm-devel mailing list
> dm-devel@redhat.com
> https://www.redhat.com/mailman/listinfo/dm-devel
> 

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

* Re: [PATCH 12/39] dm: drop null test before destroy functions
  2015-09-14 13:46   ` [dm-devel] " Mikulas Patocka
@ 2015-09-14 14:00     ` Mike Snitzer
  2015-09-14 14:05       ` Mikulas Patocka
  2015-09-14 14:23     ` [dm-devel] " walter harms
  1 sibling, 1 reply; 12+ messages in thread
From: Mike Snitzer @ 2015-09-14 14:00 UTC (permalink / raw)
  To: Mikulas Patocka
  Cc: device-mapper development, Alasdair Kergon, kernel-janitors,
	Neil Brown, linux-kernel, linux-raid, sergey.senozhatsky

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

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

* Re: [PATCH 12/39] dm: drop null test before destroy functions
  2015-09-14 14:00     ` Mike Snitzer
@ 2015-09-14 14:05       ` Mikulas Patocka
  2015-09-14 18:50         ` Julia Lawall
  0 siblings, 1 reply; 12+ messages in thread
From: Mikulas Patocka @ 2015-09-14 14:05 UTC (permalink / raw)
  To: Mike Snitzer
  Cc: device-mapper development, Alasdair Kergon, kernel-janitors,
	Neil Brown, linux-kernel, linux-raid, sergey.senozhatsky



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

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

* Re: [dm-devel] [PATCH 12/39] dm: drop null test before destroy functions
  2015-09-14 13:46   ` [dm-devel] " Mikulas Patocka
  2015-09-14 14:00     ` Mike Snitzer
@ 2015-09-14 14:23     ` walter harms
  1 sibling, 0 replies; 12+ messages in thread
From: walter harms @ 2015-09-14 14:23 UTC (permalink / raw)
  To: Mikulas Patocka
  Cc: device-mapper development, Alasdair Kergon, Mike Snitzer,
	kernel-janitors, Neil Brown, linux-kernel, linux-raid,
	sergey.senozhatsky



Am 14.09.2015 15:46, schrieb Mikulas Patocka:
> 
> 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);
>> >  	}


maybe you want to remove "kc" also
by calling kmem_cache_destroy(dm_bufio_caches[i]); directly ?

just a hint,
 wh

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

* Re: [PATCH 12/39] dm: drop null test before destroy functions
  2015-09-14 14:05       ` Mikulas Patocka
@ 2015-09-14 18:50         ` Julia Lawall
  0 siblings, 0 replies; 12+ messages in thread
From: Julia Lawall @ 2015-09-14 18:50 UTC (permalink / raw)
  To: Mikulas Patocka
  Cc: Mike Snitzer, device-mapper development, Alasdair Kergon,
	kernel-janitors, Neil Brown, linux-kernel, linux-raid,
	sergey.senozhatsky



On Mon, 14 Sep 2015, Mikulas Patocka wrote:

> 
> 
> 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.

The relevant commits were in the cover letter:

kmem_cache_destroy (commit 3942d29918522)
mempool_destroy (commit 4e3ca3e033d1)
dma_pool_destroy (commit 44d7175da6ea)

julia

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

* Re: [PATCH 17/39] md: drop null test before destroy functions
  2015-09-13 12:15 ` [PATCH 17/39] md: " Julia Lawall
@ 2015-09-15  7:29   ` Neil Brown
  0 siblings, 0 replies; 12+ messages in thread
From: Neil Brown @ 2015-09-15  7:29 UTC (permalink / raw)
  To: Julia Lawall
  Cc: sergey.senozhatsky, kernel-janitors, linux-raid, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 3464 bytes --]

Julia Lawall <Julia.Lawall@lip6.fr> writes:

> 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/multipath.c |    3 +--
>  drivers/md/raid1.c     |    6 ++----
>  drivers/md/raid10.c    |    9 +++------
>  drivers/md/raid5.c     |    3 +--
>  4 files changed, 7 insertions(+), 14 deletions(-)

Applied, thanks.

NeilBrown


>
> diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
> index 15ef2c6..09a12d7 100644
> --- a/drivers/md/raid5.c
> +++ b/drivers/md/raid5.c
> @@ -2271,8 +2271,7 @@ static void shrink_stripes(struct r5conf *conf)
>  	       drop_one_stripe(conf))
>  		;
>  
> -	if (conf->slab_cache)
> -		kmem_cache_destroy(conf->slab_cache);
> +	kmem_cache_destroy(conf->slab_cache);
>  	conf->slab_cache = NULL;
>  }
>  
> diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
> index 4517f06..5f4f553 100644
> --- a/drivers/md/raid1.c
> +++ b/drivers/md/raid1.c
> @@ -2843,8 +2843,7 @@ static struct r1conf *setup_conf(struct mddev *mddev)
>  
>   abort:
>  	if (conf) {
> -		if (conf->r1bio_pool)
> -			mempool_destroy(conf->r1bio_pool);
> +		mempool_destroy(conf->r1bio_pool);
>  		kfree(conf->mirrors);
>  		safe_put_page(conf->tmppage);
>  		kfree(conf->poolinfo);
> @@ -2946,8 +2945,7 @@ static void raid1_free(struct mddev *mddev, void *priv)
>  {
>  	struct r1conf *conf = priv;
>  
> -	if (conf->r1bio_pool)
> -		mempool_destroy(conf->r1bio_pool);
> +	mempool_destroy(conf->r1bio_pool);
>  	kfree(conf->mirrors);
>  	safe_put_page(conf->tmppage);
>  	kfree(conf->poolinfo);
> diff --git a/drivers/md/multipath.c b/drivers/md/multipath.c
> index d222522..d132f06 100644
> --- a/drivers/md/multipath.c
> +++ b/drivers/md/multipath.c
> @@ -470,8 +470,7 @@ static int multipath_run (struct mddev *mddev)
>  	return 0;
>  
>  out_free_conf:
> -	if (conf->pool)
> -		mempool_destroy(conf->pool);
> +	mempool_destroy(conf->pool);
>  	kfree(conf->multipaths);
>  	kfree(conf);
>  	mddev->private = NULL;
> diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
> index 0fc33eb..7c99a40 100644
> --- a/drivers/md/raid10.c
> +++ b/drivers/md/raid10.c
> @@ -3486,8 +3486,7 @@ static struct r10conf *setup_conf(struct mddev *mddev)
>  		printk(KERN_ERR "md/raid10:%s: couldn't allocate memory.\n",
>  		       mdname(mddev));
>  	if (conf) {
> -		if (conf->r10bio_pool)
> -			mempool_destroy(conf->r10bio_pool);
> +		mempool_destroy(conf->r10bio_pool);
>  		kfree(conf->mirrors);
>  		safe_put_page(conf->tmppage);
>  		kfree(conf);
> @@ -3682,8 +3681,7 @@ static int run(struct mddev *mddev)
>  
>  out_free_conf:
>  	md_unregister_thread(&mddev->thread);
> -	if (conf->r10bio_pool)
> -		mempool_destroy(conf->r10bio_pool);
> +	mempool_destroy(conf->r10bio_pool);
>  	safe_put_page(conf->tmppage);
>  	kfree(conf->mirrors);
>  	kfree(conf);
> @@ -3696,8 +3694,7 @@ static void raid10_free(struct mddev *mddev, void *priv)
>  {
>  	struct r10conf *conf = priv;
>  
> -	if (conf->r10bio_pool)
> -		mempool_destroy(conf->r10bio_pool);
> +	mempool_destroy(conf->r10bio_pool);
>  	safe_put_page(conf->tmppage);
>  	kfree(conf->mirrors);
>  	kfree(conf->mirrors_old);

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 818 bytes --]

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

end of thread, other threads:[~2015-09-15  7:29 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-09-13 12:14 [PATCH 00/39] drop null test before destroy functions Julia Lawall
2015-09-13 12:15 ` [PATCH 12/39] dm: " Julia Lawall
2015-09-14 13:46   ` [dm-devel] " Mikulas Patocka
2015-09-14 14:00     ` Mike Snitzer
2015-09-14 14:05       ` Mikulas Patocka
2015-09-14 18:50         ` Julia Lawall
2015-09-14 14:23     ` [dm-devel] " walter harms
2015-09-13 12:15 ` [PATCH 15/39] bcache: " Julia Lawall
2015-09-14  9:08   ` Johannes Thumshirn
2015-09-13 12:15 ` [PATCH 17/39] md: " Julia Lawall
2015-09-15  7:29   ` Neil Brown
2015-09-14 11:55 ` [PATCH 00/39] " SF Markus Elfring

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).