Re: [PATCH v3] mtd: spi-nor: cast to u64 to avoid uint overflows

2018-12-03 Thread Rafał Miłecki
On Wed, 28 Nov 2018 at 09:03, Huijin Park  wrote:
> From: "huijin.park" 
>
> 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 

You may want to adjust your git's "user.name" config to avoid
"malforming" your name (From and Signed-off-by) in the further
contributions :)

Something like
git config --global user.name "John Foo"


Re: [PATCH v3] mtd: spi-nor: cast to u64 to avoid uint overflows

2018-12-03 Thread Rafał Miłecki
On Wed, 28 Nov 2018 at 09:03, Huijin Park  wrote:
> From: "huijin.park" 
>
> 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 

You may want to adjust your git's "user.name" config to avoid
"malforming" your name (From and Signed-off-by) in the further
contributions :)

Something like
git config --global user.name "John Foo"


Re: [PATCH v3] mtd: spi-nor: cast to u64 to avoid uint overflows

2018-11-28 Thread Geert Uytterhoeven
On Wed, Nov 28, 2018 at 9:03 AM Huijin Park  wrote:
> From: "huijin.park" 
>
> 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 

Reviewed-by: Geert Uytterhoeven 

Gr{oetje,eeting}s,

Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- ge...@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds


Re: [PATCH v3] mtd: spi-nor: cast to u64 to avoid uint overflows

2018-11-28 Thread Geert Uytterhoeven
On Wed, Nov 28, 2018 at 9:03 AM Huijin Park  wrote:
> From: "huijin.park" 
>
> 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 

Reviewed-by: Geert Uytterhoeven 

Gr{oetje,eeting}s,

Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- ge...@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds


[PATCH v3] mtd: spi-nor: cast to u64 to avoid uint overflows

2018-11-28 Thread Huijin Park
From: "huijin.park" 

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 
---

Changes since v1:
 * Made commit subject and message more clear.
Changes since v2:
 * Adding the cast to only the first operand.
---
 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..59a1075 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 * info->n_sectors;
params->page_size = info->page_size;
 
/* (Fast) Read settings. */
-- 
1.7.9.5



[PATCH v3] mtd: spi-nor: cast to u64 to avoid uint overflows

2018-11-28 Thread Huijin Park
From: "huijin.park" 

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 
---

Changes since v1:
 * Made commit subject and message more clear.
Changes since v2:
 * Adding the cast to only the first operand.
---
 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..59a1075 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 * info->n_sectors;
params->page_size = info->page_size;
 
/* (Fast) Read settings. */
-- 
1.7.9.5