[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-id: <1543392134-1443-1-git-send-email-huijin.park@samsung.com>
Date: Wed, 28 Nov 2018 03:02:14 -0500
From: Huijin Park <huijin.park@...sung.com>
To: Boris Brezillon <boris.brezillon@...tlin.com>
Cc: Marek Vasut <marek.vasut@...il.com>, linux-mtd@...ts.infradead.org,
linux-kernel@...r.kernel.org,
Huijin Park <huijin.park@...sung.com>, bbanghj.park@...il.com,
Geert Uytterhoeven <geert@...ux-m68k.org>
Subject: [PATCH v3] mtd: spi-nor: cast to u64 to avoid uint overflows
From: "huijin.park" <huijin.park@...sung.com>
The "params->size" is defined as "u64".
And "info->sector_size" and "info->n_sectors" are defined as
unsigned int and u16.
Thus, u64 data might have strange data(loss data) if the result
overflows an unsigned int.
This patch casts "info->sector_size" to an u64.
Signed-off-by: huijin.park <huijin.park@...sung.com>
---
Changes since v1:
* Made commit subject and message more clear.
Changes since v2:
* Adding the cast to only the first operand.
---
drivers/mtd/spi-nor/spi-nor.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c
index d9c368c..59a1075 100644
--- a/drivers/mtd/spi-nor/spi-nor.c
+++ b/drivers/mtd/spi-nor/spi-nor.c
@@ -2459,7 +2459,7 @@ static int spi_nor_init_params(struct spi_nor *nor,
memset(params, 0, sizeof(*params));
/* Set SPI NOR sizes. */
- params->size = info->sector_size * info->n_sectors;
+ params->size = (u64)info->sector_size * info->n_sectors;
params->page_size = info->page_size;
/* (Fast) Read settings. */
--
1.7.9.5
Powered by blists - more mailing lists