Commit 6f65985e authored by Julia Lawall's avatar Julia Lawall Committed by Mike Snitzer

dm: drop NULL test before kmem_cache_destroy() and mempool_destroy()

Remove DM's unneeded NULL tests before calling these destroy functions,
now that they check for NULL, thanks to these v4.3 commits:
3942d299 ("mm/slab_common: allow NULL cache pointer in kmem_cache_destroy()")
4e3ca3e0 ("mm/mempool: allow NULL `pool' pointer in mempool_destroy()")

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: default avatarJulia Lawall <Julia.Lawall@lip6.fr>
Signed-off-by: default avatarMike Snitzer <snitzer@redhat.com>
parent 71cdb697
...@@ -1861,12 +1861,8 @@ static void __exit dm_bufio_exit(void) ...@@ -1861,12 +1861,8 @@ static void __exit dm_bufio_exit(void)
cancel_delayed_work_sync(&dm_bufio_work); cancel_delayed_work_sync(&dm_bufio_work);
destroy_workqueue(dm_bufio_wq); destroy_workqueue(dm_bufio_wq);
for (i = 0; i < ARRAY_SIZE(dm_bufio_caches); i++) { for (i = 0; i < ARRAY_SIZE(dm_bufio_caches); i++)
struct kmem_cache *kc = dm_bufio_caches[i]; kmem_cache_destroy(dm_bufio_caches[i]);
if (kc)
kmem_cache_destroy(kc);
}
for (i = 0; i < ARRAY_SIZE(dm_bufio_cache_names); i++) for (i = 0; i < ARRAY_SIZE(dm_bufio_cache_names); i++)
kfree(dm_bufio_cache_names[i]); kfree(dm_bufio_cache_names[i]);
......
...@@ -2309,7 +2309,6 @@ static void destroy(struct cache *cache) ...@@ -2309,7 +2309,6 @@ static void destroy(struct cache *cache)
{ {
unsigned i; unsigned i;
if (cache->migration_pool)
mempool_destroy(cache->migration_pool); mempool_destroy(cache->migration_pool);
if (cache->all_io_ds) if (cache->all_io_ds)
......
...@@ -1544,9 +1544,7 @@ static void crypt_dtr(struct dm_target *ti) ...@@ -1544,9 +1544,7 @@ static void crypt_dtr(struct dm_target *ti)
if (cc->bs) if (cc->bs)
bioset_free(cc->bs); bioset_free(cc->bs);
if (cc->page_pool)
mempool_destroy(cc->page_pool); mempool_destroy(cc->page_pool);
if (cc->req_pool)
mempool_destroy(cc->req_pool); mempool_destroy(cc->req_pool);
if (cc->iv_gen_ops && cc->iv_gen_ops->dtr) if (cc->iv_gen_ops && cc->iv_gen_ops->dtr)
......
...@@ -65,7 +65,6 @@ struct dm_io_client *dm_io_client_create(void) ...@@ -65,7 +65,6 @@ struct dm_io_client *dm_io_client_create(void)
return client; return client;
bad: bad:
if (client->pool)
mempool_destroy(client->pool); mempool_destroy(client->pool);
kfree(client); kfree(client);
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
......
...@@ -313,7 +313,6 @@ static int userspace_ctr(struct dm_dirty_log *log, struct dm_target *ti, ...@@ -313,7 +313,6 @@ static int userspace_ctr(struct dm_dirty_log *log, struct dm_target *ti,
out: out:
kfree(devices_rdata); kfree(devices_rdata);
if (r) { if (r) {
if (lc->flush_entry_pool)
mempool_destroy(lc->flush_entry_pool); mempool_destroy(lc->flush_entry_pool);
kfree(lc); kfree(lc);
kfree(ctr_str); kfree(ctr_str);
......
...@@ -249,9 +249,7 @@ void dm_region_hash_destroy(struct dm_region_hash *rh) ...@@ -249,9 +249,7 @@ void dm_region_hash_destroy(struct dm_region_hash *rh)
if (rh->log) if (rh->log)
dm_dirty_log_destroy(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); vfree(rh->buckets);
kfree(rh); kfree(rh);
} }
......
...@@ -2254,9 +2254,7 @@ static void cleanup_mapped_device(struct mapped_device *md) ...@@ -2254,9 +2254,7 @@ static void cleanup_mapped_device(struct mapped_device *md)
destroy_workqueue(md->wq); destroy_workqueue(md->wq);
if (md->kworker_task) if (md->kworker_task)
kthread_stop(md->kworker_task); kthread_stop(md->kworker_task);
if (md->io_pool)
mempool_destroy(md->io_pool); mempool_destroy(md->io_pool);
if (md->rq_pool)
mempool_destroy(md->rq_pool); mempool_destroy(md->rq_pool);
if (md->bs) if (md->bs)
bioset_free(md->bs); bioset_free(md->bs);
...@@ -3542,10 +3540,7 @@ void dm_free_md_mempools(struct dm_md_mempools *pools) ...@@ -3542,10 +3540,7 @@ void dm_free_md_mempools(struct dm_md_mempools *pools)
if (!pools) if (!pools)
return; return;
if (pools->io_pool)
mempool_destroy(pools->io_pool); mempool_destroy(pools->io_pool);
if (pools->rq_pool)
mempool_destroy(pools->rq_pool); mempool_destroy(pools->rq_pool);
if (pools->bs) if (pools->bs)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment