aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorJesper Juhl <juhl-lkml@dif.dk>2005-06-21 20:17:30 -0400
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-06-21 22:07:48 -0400
commit990a8baf568ca1d0ae65e59783ff821794118d07 (patch)
tree1fe187b2f119f7a9d96d56380b211f9ddb9f8390 /drivers
parent8a5e9cf1d6626586ff08e49f400a006a9f0c3275 (diff)
[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>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/md/dm-crypt.c3
-rw-r--r--drivers/md/linear.c3
-rw-r--r--drivers/md/md.c10
-rw-r--r--drivers/md/multipath.c3
-rw-r--r--drivers/md/raid0.c12
-rw-r--r--drivers/md/raid1.c12
-rw-r--r--drivers/md/raid10.c6
7 files changed, 17 insertions, 32 deletions
diff --git a/drivers/md/dm-crypt.c b/drivers/md/dm-crypt.c
index 0dd6c2b5391b..d0a4bab220e5 100644
--- a/drivers/md/dm-crypt.c
+++ b/drivers/md/dm-crypt.c
@@ -704,8 +704,7 @@ static void crypt_dtr(struct dm_target *ti)
704 mempool_destroy(cc->page_pool); 704 mempool_destroy(cc->page_pool);
705 mempool_destroy(cc->io_pool); 705 mempool_destroy(cc->io_pool);
706 706
707 if (cc->iv_mode) 707 kfree(cc->iv_mode);
708 kfree(cc->iv_mode);
709 if (cc->iv_gen_ops && cc->iv_gen_ops->dtr) 708 if (cc->iv_gen_ops && cc->iv_gen_ops->dtr)
710 cc->iv_gen_ops->dtr(cc); 709 cc->iv_gen_ops->dtr(cc);
711 crypto_free_tfm(cc->tfm); 710 crypto_free_tfm(cc->tfm);
diff --git a/drivers/md/linear.c b/drivers/md/linear.c
index b1941b887f46..8d740013d74d 100644
--- a/drivers/md/linear.c
+++ b/drivers/md/linear.c
@@ -217,8 +217,7 @@ static int linear_run (mddev_t *mddev)
217 return 0; 217 return 0;
218 218
219out: 219out:
220 if (conf) 220 kfree(conf);
221 kfree(conf);
222 return 1; 221 return 1;
223} 222}
224 223
diff --git a/drivers/md/md.c b/drivers/md/md.c
index 65fab74ad737..0c6b5b6baff6 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -195,8 +195,7 @@ static mddev_t * mddev_find(dev_t unit)
195 if (mddev->unit == unit) { 195 if (mddev->unit == unit) {
196 mddev_get(mddev); 196 mddev_get(mddev);
197 spin_unlock(&all_mddevs_lock); 197 spin_unlock(&all_mddevs_lock);
198 if (new) 198 kfree(new);
199 kfree(new);
200 return mddev; 199 return mddev;
201 } 200 }
202 201
@@ -458,11 +457,8 @@ static int sb_equal(mdp_super_t *sb1, mdp_super_t *sb2)
458 ret = 1; 457 ret = 1;
459 458
460abort: 459abort:
461 if (tmp1) 460 kfree(tmp1);
462 kfree(tmp1); 461 kfree(tmp2);
463 if (tmp2)
464 kfree(tmp2);
465
466 return ret; 462 return ret;
467} 463}
468 464
diff --git a/drivers/md/multipath.c b/drivers/md/multipath.c
index 2ae2d709cb15..2d2ca7fa0265 100644
--- a/drivers/md/multipath.c
+++ b/drivers/md/multipath.c
@@ -533,8 +533,7 @@ static int multipath_run (mddev_t *mddev)
533out_free_conf: 533out_free_conf:
534 if (conf->pool) 534 if (conf->pool)
535 mempool_destroy(conf->pool); 535 mempool_destroy(conf->pool);
536 if (conf->multipaths) 536 kfree(conf->multipaths);
537 kfree(conf->multipaths);
538 kfree(conf); 537 kfree(conf);
539 mddev->private = NULL; 538 mddev->private = NULL;
540out: 539out:
diff --git a/drivers/md/raid0.c b/drivers/md/raid0.c
index e7d934eca06f..e11dd14d0b43 100644
--- a/drivers/md/raid0.c
+++ b/drivers/md/raid0.c
@@ -371,10 +371,8 @@ static int raid0_run (mddev_t *mddev)
371 return 0; 371 return 0;
372 372
373out_free_conf: 373out_free_conf:
374 if (conf->strip_zone) 374 kfree(conf->strip_zone);
375 kfree(conf->strip_zone); 375 kfree(conf->devlist);
376 if (conf->devlist)
377 kfree (conf->devlist);
378 kfree(conf); 376 kfree(conf);
379 mddev->private = NULL; 377 mddev->private = NULL;
380out: 378out:
@@ -386,11 +384,11 @@ static int raid0_stop (mddev_t *mddev)
386 raid0_conf_t *conf = mddev_to_conf(mddev); 384 raid0_conf_t *conf = mddev_to_conf(mddev);
387 385
388 blk_sync_queue(mddev->queue); /* the unplug fn references 'conf'*/ 386 blk_sync_queue(mddev->queue); /* the unplug fn references 'conf'*/
389 kfree (conf->hash_table); 387 kfree(conf->hash_table);
390 conf->hash_table = NULL; 388 conf->hash_table = NULL;
391 kfree (conf->strip_zone); 389 kfree(conf->strip_zone);
392 conf->strip_zone = NULL; 390 conf->strip_zone = NULL;
393 kfree (conf); 391 kfree(conf);
394 mddev->private = NULL; 392 mddev->private = NULL;
395 393
396 return 0; 394 return 0;
diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
index 98b09773e79e..ff1dbec864af 100644
--- a/drivers/md/raid1.c
+++ b/drivers/md/raid1.c
@@ -1427,10 +1427,8 @@ out_free_conf:
1427 if (conf) { 1427 if (conf) {
1428 if (conf->r1bio_pool) 1428 if (conf->r1bio_pool)
1429 mempool_destroy(conf->r1bio_pool); 1429 mempool_destroy(conf->r1bio_pool);
1430 if (conf->mirrors) 1430 kfree(conf->mirrors);
1431 kfree(conf->mirrors); 1431 kfree(conf->poolinfo);
1432 if (conf->poolinfo)
1433 kfree(conf->poolinfo);
1434 kfree(conf); 1432 kfree(conf);
1435 mddev->private = NULL; 1433 mddev->private = NULL;
1436 } 1434 }
@@ -1447,10 +1445,8 @@ static int stop(mddev_t *mddev)
1447 blk_sync_queue(mddev->queue); /* the unplug fn references 'conf'*/ 1445 blk_sync_queue(mddev->queue); /* the unplug fn references 'conf'*/
1448 if (conf->r1bio_pool) 1446 if (conf->r1bio_pool)
1449 mempool_destroy(conf->r1bio_pool); 1447 mempool_destroy(conf->r1bio_pool);
1450 if (conf->mirrors) 1448 kfree(conf->mirrors);
1451 kfree(conf->mirrors); 1449 kfree(conf->poolinfo);
1452 if (conf->poolinfo)
1453 kfree(conf->poolinfo);
1454 kfree(conf); 1450 kfree(conf);
1455 mddev->private = NULL; 1451 mddev->private = NULL;
1456 return 0; 1452 return 0;
diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
index fd7324a86d13..62ebb1bc72be 100644
--- a/drivers/md/raid10.c
+++ b/drivers/md/raid10.c
@@ -1737,8 +1737,7 @@ static int run(mddev_t *mddev)
1737out_free_conf: 1737out_free_conf:
1738 if (conf->r10bio_pool) 1738 if (conf->r10bio_pool)
1739 mempool_destroy(conf->r10bio_pool); 1739 mempool_destroy(conf->r10bio_pool);
1740 if (conf->mirrors) 1740 kfree(conf->mirrors);
1741 kfree(conf->mirrors);
1742 kfree(conf); 1741 kfree(conf);
1743 mddev->private = NULL; 1742 mddev->private = NULL;
1744out: 1743out:
@@ -1754,8 +1753,7 @@ static int stop(mddev_t *mddev)
1754 blk_sync_queue(mddev->queue); /* the unplug fn references 'conf'*/ 1753 blk_sync_queue(mddev->queue); /* the unplug fn references 'conf'*/
1755 if (conf->r10bio_pool) 1754 if (conf->r10bio_pool)
1756 mempool_destroy(conf->r10bio_pool); 1755 mempool_destroy(conf->r10bio_pool);
1757 if (conf->mirrors) 1756 kfree(conf->mirrors);
1758 kfree(conf->mirrors);
1759 kfree(conf); 1757 kfree(conf);
1760 mddev->private = NULL; 1758 mddev->private = NULL;
1761 return 0; 1759 return 0;