[PATCH 3/3] mtd-rfd_ftl: Refactoring for erase_block()

SF Markus Elfring
2015-12-31T20:27:40Z

Date: Thu, 31 Dec 2015 21:06:27 +0100

This issue was detected by using the Coccinelle software.

* Return directly if a memory allocation failed.

* Drop the explicit initialisation for the variable "rc"
at the beginning then.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/mtd/rfd_ftl.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/mtd/rfd_ftl.c b/drivers/mtd/rfd_ftl.c
index 9b59423..8379447 100644
--- a/drivers/mtd/rfd_ftl.c
+++ b/drivers/mtd/rfd_ftl.c
@@ -326,11 +326,11 @@ static void erase_callback(struct erase_info *erase)
static int erase_block(struct partition *part, int block)
{
struct erase_info *erase;
- int rc = -ENOMEM;
+ int rc;

erase = kmalloc(sizeof(struct erase_info), GFP_KERNEL);
if (!erase)
- goto err;
+ return -ENOMEM;

erase->mtd = part->mbd.mtd;
erase->callback = erase_callback;
@@ -349,8 +349,6 @@ static int erase_block(struct partition *part, int block)
(unsigned long long)erase->len, part->mbd.mtd->name);
kfree(erase);
}
-
-err:
return rc;
}

--
2.6.3