From: SF Markus Elfring Date: Sat, 06 Jan 2018 15:09:44 +0000 Subject: [PATCH 3/5] mtd/rfd_ftl: Improve a size determination in two functions Message-Id: List-Id: References: In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: linux-mtd@lists.infradead.org, Boris Brezillon , Brian Norris , Cyrille Pitchen , David Woodhouse , Marek Vasut , Richard Weinberger Cc: LKML , kernel-janitors@vger.kernel.org From: Markus Elfring 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 --- 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