lkml.org 
[lkml]   [2018]   [Jan]   [6]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Subject[PATCH 3/5] mtd/rfd_ftl: Improve a size determination in two functions
From
Date
From: Markus Elfring <elfring@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@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
\
 
 \ /
  Last update: 2018-01-06 16:11    [W:0.027 / U:2.668 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site