lkml.org 
[lkml]   [2018]   [Nov]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRE: [PATCH] mtd: spi-nor: cast to u64 to avoid uint overflows
Date
Hi Huijin,

I guess this is the v2 of previously send patch [1], please follow version information in patch submission.

--
Regards
Yogesh Gaur
[1] https://patchwork.ozlabs.org/patch/961197/


> -----Original Message-----
> From: linux-mtd [mailto:linux-mtd-bounces@lists.infradead.org] On Behalf Of
> Huijin Park
> Sent: Tuesday, November 13, 2018 10:49 AM
> To: Boris Brezillon <boris.brezillon@bootlin.com>
> Cc: Marek Vasut <marek.vasut@gmail.com>; linux-mtd@lists.infradead.org;
> linux-kernel@vger.kernel.org; bbanghj.park@gmail.com; Huijin Park
> <huijin.park@samsung.com>
> Subject: [PATCH] mtd: spi-nor: cast to u64 to avoid uint overflows
>
> From: "huijin.park" <huijin.park@samsung.com>
>
> 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" and "info->n_sectors" to an u64.
>
> Signed-off-by: huijin.park <huijin.park@samsung.com>
> ---
> drivers/mtd/spi-nor/spi-nor.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c index
> d9c368c..527f281 100644
> --- 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 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 * (u64)info->n_sectors;
> params->page_size = info->page_size;
>
> /* (Fast) Read settings. */
> --
> 1.7.9.5
>
>
> ______________________________________________________
> Linux MTD discussion mailing list
> https://emea01.safelinks.protection.outlook.com/?url=http%3A%2F%2Flists.infr
> adead.org%2Fmailman%2Flistinfo%2Flinux-
> mtd%2F&amp;data=02%7C01%7Cyogeshnarayan.gaur%40nxp.com%7C5efd964
> 86c7244f430b408d649278b65%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%
> 7C1%7C636776831529836639&amp;sdata=A7hiJMpfxXKTyT6yacIougPRGdHg2o
> pL492y3sVtQek%3D&amp;reserved=0

\
 
 \ /
  Last update: 2018-11-13 07:40    [W:0.111 / U:0.036 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site