mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-12 13:55:32 +00:00
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>
This commit is contained in:
parent
4cc106f8f2
commit
84a1c2109d
1 changed files with 1 additions and 1 deletions
|
@ -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. */
|
||||
|
|
Loading…
Reference in a new issue