[PATCH 3/5] mtd/rfd_ftl: Improve a size determination in two functions
SF Markus Elfring
elfring at users.sourceforge.net
Sat Jan 6 07:09:44 PST 2018
From: Markus Elfring <elfring at users.sourceforge.net>
Date: Sat, 6 Jan 2018 15:03:29 +0100
Replace the specification of data structures by pointer dereferences
as the parameter for the operator "sizeof" to make the corresponding size
determination a bit safer according to the Linux coding style convention.
This issue was detected by using the Coccinelle software.
Signed-off-by: Markus Elfring <elfring at users.sourceforge.net>
---
drivers/mtd/rfd_ftl.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/drivers/mtd/rfd_ftl.c b/drivers/mtd/rfd_ftl.c
index 19e14f909dc6..dcf1b88e1193 100644
--- a/drivers/mtd/rfd_ftl.c
+++ b/drivers/mtd/rfd_ftl.c
@@ -323,10 +323,9 @@ static void erase_callback(struct erase_info *erase)
static int erase_block(struct partition *part, int block)
{
- struct erase_info *erase;
int rc = -ENOMEM;
+ struct erase_info *erase = kmalloc(sizeof(*erase), GFP_KERNEL);
- erase = kmalloc(sizeof(struct erase_info), GFP_KERNEL);
if (!erase)
goto err;
@@ -759,7 +758,7 @@ static void rfd_ftl_add_mtd(struct mtd_blktrans_ops *tr, struct mtd_info *mtd)
if (mtd->type != MTD_NORFLASH || mtd->size > UINT_MAX)
return;
- part = kzalloc(sizeof(struct partition), GFP_KERNEL);
+ part = kzalloc(sizeof(*part), GFP_KERNEL);
if (!part)
return;
--
2.15.1
More information about the linux-mtd
mailing list