Skip to content

Commit

Permalink
md: drop null test before destroy functions
Browse files Browse the repository at this point in the history
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>
Signed-off-by: NeilBrown <neilb@suse.com>
  • Loading branch information
Julia Lawall authored and NeilBrown committed Oct 2, 2015
1 parent d4929ad commit 644df1a
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 14 deletions.
3 changes: 1 addition & 2 deletions drivers/md/multipath.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 2 additions & 4 deletions drivers/md/raid1.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
9 changes: 3 additions & 6 deletions drivers/md/raid10.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand Down
3 changes: 1 addition & 2 deletions drivers/md/raid5.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit 644df1a

Please sign in to comment.