[PATCH] md: remove unneeded NULL checks before kfree

This patch removes some unneeded checks of pointers being NULL before
calling kfree() on them.  kfree() handles NULL pointers just fine, checking
first is pointless.

Signed-off-by: Jesper Juhl <juhl-lkml@dif.dk>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
This commit is contained in:
Jesper Juhl 2005-06-21 17:17:30 -07:00 committed by Linus Torvalds
parent 8a5e9cf1d6
commit 990a8baf56
7 changed files with 17 additions and 32 deletions

View file

@ -704,7 +704,6 @@ static void crypt_dtr(struct dm_target *ti)
mempool_destroy(cc->page_pool); mempool_destroy(cc->page_pool);
mempool_destroy(cc->io_pool); mempool_destroy(cc->io_pool);
if (cc->iv_mode)
kfree(cc->iv_mode); kfree(cc->iv_mode);
if (cc->iv_gen_ops && cc->iv_gen_ops->dtr) if (cc->iv_gen_ops && cc->iv_gen_ops->dtr)
cc->iv_gen_ops->dtr(cc); cc->iv_gen_ops->dtr(cc);

View file

@ -217,7 +217,6 @@ static int linear_run (mddev_t *mddev)
return 0; return 0;
out: out:
if (conf)
kfree(conf); kfree(conf);
return 1; return 1;
} }

View file

@ -195,7 +195,6 @@ static mddev_t * mddev_find(dev_t unit)
if (mddev->unit == unit) { if (mddev->unit == unit) {
mddev_get(mddev); mddev_get(mddev);
spin_unlock(&all_mddevs_lock); spin_unlock(&all_mddevs_lock);
if (new)
kfree(new); kfree(new);
return mddev; return mddev;
} }
@ -458,11 +457,8 @@ static int sb_equal(mdp_super_t *sb1, mdp_super_t *sb2)
ret = 1; ret = 1;
abort: abort:
if (tmp1)
kfree(tmp1); kfree(tmp1);
if (tmp2)
kfree(tmp2); kfree(tmp2);
return ret; return ret;
} }

View file

@ -533,7 +533,6 @@ static int multipath_run (mddev_t *mddev)
out_free_conf: out_free_conf:
if (conf->pool) if (conf->pool)
mempool_destroy(conf->pool); mempool_destroy(conf->pool);
if (conf->multipaths)
kfree(conf->multipaths); kfree(conf->multipaths);
kfree(conf); kfree(conf);
mddev->private = NULL; mddev->private = NULL;

View file

@ -371,9 +371,7 @@ static int raid0_run (mddev_t *mddev)
return 0; return 0;
out_free_conf: out_free_conf:
if (conf->strip_zone)
kfree(conf->strip_zone); kfree(conf->strip_zone);
if (conf->devlist)
kfree(conf->devlist); kfree(conf->devlist);
kfree(conf); kfree(conf);
mddev->private = NULL; mddev->private = NULL;

View file

@ -1427,9 +1427,7 @@ out_free_conf:
if (conf) { if (conf) {
if (conf->r1bio_pool) if (conf->r1bio_pool)
mempool_destroy(conf->r1bio_pool); mempool_destroy(conf->r1bio_pool);
if (conf->mirrors)
kfree(conf->mirrors); kfree(conf->mirrors);
if (conf->poolinfo)
kfree(conf->poolinfo); kfree(conf->poolinfo);
kfree(conf); kfree(conf);
mddev->private = NULL; mddev->private = NULL;
@ -1447,9 +1445,7 @@ static int stop(mddev_t *mddev)
blk_sync_queue(mddev->queue); /* the unplug fn references 'conf'*/ blk_sync_queue(mddev->queue); /* the unplug fn references 'conf'*/
if (conf->r1bio_pool) if (conf->r1bio_pool)
mempool_destroy(conf->r1bio_pool); mempool_destroy(conf->r1bio_pool);
if (conf->mirrors)
kfree(conf->mirrors); kfree(conf->mirrors);
if (conf->poolinfo)
kfree(conf->poolinfo); kfree(conf->poolinfo);
kfree(conf); kfree(conf);
mddev->private = NULL; mddev->private = NULL;

View file

@ -1737,7 +1737,6 @@ static int run(mddev_t *mddev)
out_free_conf: out_free_conf:
if (conf->r10bio_pool) if (conf->r10bio_pool)
mempool_destroy(conf->r10bio_pool); mempool_destroy(conf->r10bio_pool);
if (conf->mirrors)
kfree(conf->mirrors); kfree(conf->mirrors);
kfree(conf); kfree(conf);
mddev->private = NULL; mddev->private = NULL;
@ -1754,7 +1753,6 @@ static int stop(mddev_t *mddev)
blk_sync_queue(mddev->queue); /* the unplug fn references 'conf'*/ blk_sync_queue(mddev->queue); /* the unplug fn references 'conf'*/
if (conf->r10bio_pool) if (conf->r10bio_pool)
mempool_destroy(conf->r10bio_pool); mempool_destroy(conf->r10bio_pool);
if (conf->mirrors)
kfree(conf->mirrors); kfree(conf->mirrors);
kfree(conf); kfree(conf);
mddev->private = NULL; mddev->private = NULL;