mtd: sharpslpart: fix overflow on block_adr calculation
authorColin Ian King <colin.king@canonical.com>
Wed, 8 Nov 2017 16:13:23 +0000 (16:13 +0000)
committerBoris Brezillon <boris.brezillon@free-electrons.com>
Mon, 18 Dec 2017 12:30:04 +0000 (13:30 +0100)
commitb1d030f804fbf8f502756231d475fcf8fd6a86ad
treed3114c6ab32e1e67840f5cfb0ae0104886deb9bc
parent9e343e87d2c4c707ef8fae2844864d4dde3a2d13
mtd: sharpslpart: fix overflow on block_adr calculation

Multiplying block_num and mtd->erasesize may potentially overflow
as they are both unsigned ints and so the multiplication is evaluated
in unsigned int arithmetic.  Cast block_adr to off_t to ensure
multiplication is off_t sized to avoid any potential overflow.

Detected by CoverityScan, CID#1461264 ("Unintentional integer overflow")

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Acked-by: Andrea Adami <andrea.adami@gmail.com>
Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
drivers/mtd/parsers/sharpslpart.c