diff options
author | huijin.park <huijin.park@samsung.com> | 2018-11-28 03:02:14 -0500 |
---|---|---|
committer | Boris Brezillon <boris.brezillon@bootlin.com> | 2018-12-10 21:59:07 +0100 |
commit | 84a1c2109d23df3543d96231c4fee1757299bb1a (patch) | |
tree | e025f78f761dd94e0a503ab52437e1c4b6f9b65d /drivers | |
parent | 4cc106f8f245bae0c458224804733240cb22394d (diff) |
mtd: spi-nor: cast to u64 to avoid uint overflows
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@samsung.com>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/mtd/spi-nor/spi-nor.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c index 9ad2c8329931..1423bbaa9762 100644 --- a/drivers/mtd/spi-nor/spi-nor.c +++ b/drivers/mtd/spi-nor/spi-nor.c @@ -3270,7 +3270,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. */ |