[PATCH] md: remove unneeded NULL checks before kfree
authorJesper Juhl <juhl-lkml@dif.dk>
Wed, 22 Jun 2005 00:17:30 +0000 (17:17 -0700)
committerLinus Torvalds <torvalds@ppc970.osdl.org>
Wed, 22 Jun 2005 02:07:48 +0000 (19:07 -0700)
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>
drivers/md/dm-crypt.c
drivers/md/linear.c
drivers/md/md.c
drivers/md/multipath.c
drivers/md/raid0.c
drivers/md/raid1.c
drivers/md/raid10.c

index 0dd6c2b5391b754a9aa4bc01e87d97c4c86672b3..d0a4bab220e5e6b5608e50810b3dead70e7be095 100644 (file)
@@ -704,8 +704,7 @@ static void crypt_dtr(struct dm_target *ti)
        mempool_destroy(cc->page_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)
                cc->iv_gen_ops->dtr(cc);
        crypto_free_tfm(cc->tfm);
index b1941b887f46fd6f7f5a991cbb969778ecd31c61..8d740013d74d5eff047d99f02d1f93d7b65218bd 100644 (file)
@@ -217,8 +217,7 @@ static int linear_run (mddev_t *mddev)
        return 0;
 
 out:
-       if (conf)
-               kfree(conf);
+       kfree(conf);
        return 1;
 }
 
index 65fab74ad7377b110a135215f4054d95f6df586f..0c6b5b6baff60ded7fb24d2f71988711d723c604 100644 (file)
@@ -195,8 +195,7 @@ static mddev_t * mddev_find(dev_t unit)
                if (mddev->unit == unit) {
                        mddev_get(mddev);
                        spin_unlock(&all_mddevs_lock);
-                       if (new)
-                               kfree(new);
+                       kfree(new);
                        return mddev;
                }
 
@@ -458,11 +457,8 @@ static int sb_equal(mdp_super_t *sb1, mdp_super_t *sb2)
                ret = 1;
 
 abort:
-       if (tmp1)
-               kfree(tmp1);
-       if (tmp2)
-               kfree(tmp2);
-
+       kfree(tmp1);
+       kfree(tmp2);
        return ret;
 }
 
index 2ae2d709cb1582256699b7c915436a2476129966..2d2ca7fa0265261a71e2493e88b68403cc902c57 100644 (file)
@@ -533,8 +533,7 @@ static int multipath_run (mddev_t *mddev)
 out_free_conf:
        if (conf->pool)
                mempool_destroy(conf->pool);
-       if (conf->multipaths)
-               kfree(conf->multipaths);
+       kfree(conf->multipaths);
        kfree(conf);
        mddev->private = NULL;
 out:
index e7d934eca06f8de135d9cd5b545735422bc57790..e11dd14d0b43f4700f7a9779a0ed6d7676461aa4 100644 (file)
@@ -371,10 +371,8 @@ static int raid0_run (mddev_t *mddev)
        return 0;
 
 out_free_conf:
-       if (conf->strip_zone)
-               kfree(conf->strip_zone);
-       if (conf->devlist)
-               kfree (conf->devlist);
+       kfree(conf->strip_zone);
+       kfree(conf->devlist);
        kfree(conf);
        mddev->private = NULL;
 out:
@@ -386,11 +384,11 @@ static int raid0_stop (mddev_t *mddev)
        raid0_conf_t *conf = mddev_to_conf(mddev);
 
        blk_sync_queue(mddev->queue); /* the unplug fn references 'conf'*/
-       kfree (conf->hash_table);
+       kfree(conf->hash_table);
        conf->hash_table = NULL;
-       kfree (conf->strip_zone);
+       kfree(conf->strip_zone);
        conf->strip_zone = NULL;
-       kfree (conf);
+       kfree(conf);
        mddev->private = NULL;
 
        return 0;
index 98b09773e79ec2a1e636f5ee419f0d39cb9cae00..ff1dbec864af51d780e1135ae392c1f6962ae37c 100644 (file)
@@ -1427,10 +1427,8 @@ out_free_conf:
        if (conf) {
                if (conf->r1bio_pool)
                        mempool_destroy(conf->r1bio_pool);
-               if (conf->mirrors)
-                       kfree(conf->mirrors);
-               if (conf->poolinfo)
-                       kfree(conf->poolinfo);
+               kfree(conf->mirrors);
+               kfree(conf->poolinfo);
                kfree(conf);
                mddev->private = NULL;
        }
@@ -1447,10 +1445,8 @@ static int stop(mddev_t *mddev)
        blk_sync_queue(mddev->queue); /* the unplug fn references 'conf'*/
        if (conf->r1bio_pool)
                mempool_destroy(conf->r1bio_pool);
-       if (conf->mirrors)
-               kfree(conf->mirrors);
-       if (conf->poolinfo)
-               kfree(conf->poolinfo);
+       kfree(conf->mirrors);
+       kfree(conf->poolinfo);
        kfree(conf);
        mddev->private = NULL;
        return 0;
index fd7324a86d1344e86952759f23a0c874e5bd37fc..62ebb1bc72be24cc32ecc775c5bd71603d44e5c6 100644 (file)
@@ -1737,8 +1737,7 @@ static int run(mddev_t *mddev)
 out_free_conf:
        if (conf->r10bio_pool)
                mempool_destroy(conf->r10bio_pool);
-       if (conf->mirrors)
-               kfree(conf->mirrors);
+       kfree(conf->mirrors);
        kfree(conf);
        mddev->private = NULL;
 out:
@@ -1754,8 +1753,7 @@ static int stop(mddev_t *mddev)
        blk_sync_queue(mddev->queue); /* the unplug fn references 'conf'*/
        if (conf->r10bio_pool)
                mempool_destroy(conf->r10bio_pool);
-       if (conf->mirrors)
-               kfree(conf->mirrors);
+       kfree(conf->mirrors);
        kfree(conf);
        mddev->private = NULL;
        return 0;