[PATCH 2/3] mtd/nand/ams-delta: Improve a size determination in ams_delta_init()

SF Markus Elfring elfring at users.sourceforge.net
Fri Jan 5 12:30:00 PST 2018


From: Markus Elfring <elfring at users.sourceforge.net>
Date: Fri, 5 Jan 2018 21:03:20 +0100

Replace the specification of a data structure by a pointer dereference
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/nand/ams-delta.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/mtd/nand/ams-delta.c b/drivers/mtd/nand/ams-delta.c
index effaecff0f2e..4f5fc104c510 100644
--- a/drivers/mtd/nand/ams-delta.c
+++ b/drivers/mtd/nand/ams-delta.c
@@ -183,7 +183,7 @@ static int ams_delta_init(struct platform_device *pdev)
 		return -ENXIO;
 
 	/* Allocate memory for MTD device structure and private data */
-	this = kzalloc(sizeof(struct nand_chip), GFP_KERNEL);
+	this = kzalloc(sizeof(*this), GFP_KERNEL);
 	if (!this) {
 		err = -ENOMEM;
 		goto out;
-- 
2.15.1




More information about the linux-mtd mailing list