lkml.org 
[lkml]   [2019]   [Dec]   [3]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 4.19 300/321] mtd: spi-nor: cast to u64 to avoid uint overflows
    Date
    From: huijin.park <huijin.park@samsung.com>

    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>

    ---
    drivers/mtd/spi-nor/spi-nor.c | 2 +-
    1 file changed, 1 insertion(+), 1 deletion(-)

    --- 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 sp
    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. */

    \
     
     \ /
      Last update: 2019-12-03 23:59    [W:4.780 / U:2.944 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site