From: Huijin Park <huijin.park@samsung.com>
To: Marek Vasut <marek.vasut@gmail.com>
Cc: Boris Brezillon <boris.brezillon@bootlin.com>,
Huijin Park <huijin.park@samsung.com>,
bbanghj.park@gmail.com, linux-mtd@lists.infradead.org,
linux-kernel@vger.kernel.org
Subject: [PATCH] mtd: cast to u64 to avoid unexpected error
Date: Thu, 23 Aug 2018 03:28:02 -0400 [thread overview]
Message-ID: <1535009282-1480-1-git-send-email-huijin.park@samsung.com> (raw)
In-Reply-To: CGME20180823072813eucas1p2a534b4be94a3a2bc3480adcefca2ca22@eucas1p2.samsung.com
From: "huijin.park" <huijin.park@samsung.com>
the params->size is defined as "u64"
and, "info->sector_size" and "info->n_sectors" is defined as unsgined and u16
thus, u64 data might have strange data(loss data) if data is overflow.
this patch cast it to 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
next parent reply other threads:[~2018-08-23 7:28 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CGME20180823072813eucas1p2a534b4be94a3a2bc3480adcefca2ca22@eucas1p2.samsung.com>
2018-08-23 7:28 ` Huijin Park [this message]
2018-10-31 13:55 ` [PATCH] mtd: cast to u64 to avoid unexpected error Boris Brezillon
2018-11-12 16:12 ` Huijin Park
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1535009282-1480-1-git-send-email-huijin.park@samsung.com \
--to=huijin.park@samsung.com \
--cc=bbanghj.park@gmail.com \
--cc=boris.brezillon@bootlin.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mtd@lists.infradead.org \
--cc=marek.vasut@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).