]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
mtd: spi-nor: cast to u64 to avoid uint overflows
authorhuijin.park <huijin.park@samsung.com>
Wed, 28 Nov 2018 08:02:14 +0000 (03:02 -0500)
committerMarcelo Henrique Cerri <marcelo.cerri@canonical.com>
Fri, 17 Jan 2020 17:21:46 +0000 (14:21 -0300)
BugLink: https://bugs.launchpad.net/bugs/1855787
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: huijin.park <huijin.park@samsung.com>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
drivers/mtd/spi-nor/spi-nor.c

index 876323025b789bd0ebed884ac4f57b2bcf9db41e..ab74aea8d2403cf52f13aefcaad162034cee84cb 100644 (file)
@@ -2402,7 +2402,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. */