[PATCH 11/22] kfree simplifications

Jörn Engel joern at wohnheim.fh-wedel.de
Tue Dec 21 08:54:05 EST 2004


kfree(NULL) works just fine, which allows for much simpler code.

Signed-off-by: Jörn Engel <joern at wohnheim.fh-wedel.de>
---

 blockmtd.c |   26 +++++++++++++-------------
 1 files changed, 13 insertions(+), 13 deletions(-)

--- linux-2.6.9cow/drivers/mtd/devices/blockmtd.c~blockmtd_kfree	2004-12-20 22:12:07.000000000 +0100
+++ linux-2.6.9cow/drivers/mtd/devices/blockmtd.c	2004-12-20 22:14:47.000000000 +0100
@@ -342,20 +342,20 @@
 	return;
 }
 
-static void free_device(struct blkmtd_dev *dev)
+static void blockmtd_free_device(struct blkmtd_dev *dev)
 {
-	if (dev) {
-		if (dev->mtd_info.eraseregions)
-			kfree(dev->mtd_info.eraseregions);
-		if (dev->mtd_info.name)
-			kfree(dev->mtd_info.name);
+	if (!dev)
+		return;
 
-		if (dev->blkdev) {
-			invalidate_inode_pages(dev->blkdev->bd_inode->i_mapping);
-			close_bdev_excl(dev->blkdev);
-		}
-		kfree(dev);
+	kfree(dev->mtd_info.eraseregions);
+	kfree(dev->mtd_info.name);
+
+	if (dev->blkdev) {
+		invalidate_inode_pages(dev->blkdev->bd_inode->i_mapping);
+		close_bdev_excl(dev->blkdev);
 	}
+
+	kfree(dev);
 }
 
 
@@ -496,7 +496,7 @@
 	return dev;
 
 devinit_err:
-	free_device(dev);
+	blockmtd_free_device(dev);
 	return NULL;
 }
 
@@ -629,7 +629,7 @@
 		INFO("mtd%d: [%s] removed", dev->mtd_info.index,
 				dev->mtd_info.name + strlen("blkmtd: "));
 		list_del(&dev->list);
-		free_device(dev);
+		blockmtd_free_device(dev);
 	}
 }
 




More information about the linux-mtd mailing list