[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <dc2790d6-6c96-65e4-5407-a2440f5a97e8@users.sourceforge.net>
Date: Sat, 6 Jan 2018 16:09:44 +0100
From: SF Markus Elfring <elfring@...rs.sourceforge.net>
To: linux-mtd@...ts.infradead.org,
Boris Brezillon <boris.brezillon@...e-electrons.com>,
Brian Norris <computersforpeace@...il.com>,
Cyrille Pitchen <cyrille.pitchen@...ev4u.fr>,
David Woodhouse <dwmw2@...radead.org>,
Marek Vasut <marek.vasut@...il.com>,
Richard Weinberger <richard@....at>
Cc: LKML <linux-kernel@...r.kernel.org>,
kernel-janitors@...r.kernel.org
Subject: [PATCH 3/5] mtd/rfd_ftl: Improve a size determination in two
functions
From: Markus Elfring <elfring@...rs.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@...rs.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
Powered by blists - more mailing lists