提交 37b5fff3 编写于 作者: H huijin.park 提交者: Greg Kroah-Hartman

mtd: spi-nor: cast to u64 to avoid uint overflows

commit 84a1c2109d23df3543d96231c4fee1757299bb1a upstream.

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: Nhuijin.park <huijin.park@samsung.com>
Reviewed-by: NGeert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: NBoris Brezillon <boris.brezillon@bootlin.com>
Signed-off-by: NLee Jones <lee.jones@linaro.org>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
上级 4535def7
...@@ -2459,7 +2459,7 @@ static int spi_nor_init_params(struct spi_nor *nor, ...@@ -2459,7 +2459,7 @@ static int spi_nor_init_params(struct spi_nor *nor,
memset(params, 0, sizeof(*params)); memset(params, 0, sizeof(*params));
/* Set SPI NOR sizes. */ /* 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; params->page_size = info->page_size;
/* (Fast) Read settings. */ /* (Fast) Read settings. */
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册