Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mtd: partitions: redboot: Added conversion of operands to a larger type

The value of an arithmetic expression directory * master->erasesize is
subject to overflow due to a failure to cast operands to a larger data
type before perfroming arithmetic

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Signed-off-by: Denis Arefev <arefev@swemel.ru>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20240315093758.20790-1-arefev@swemel.ru

authored by

Denis Arefev and committed by
Miquel Raynal
1162bc2f 26729dbb

+1 -1
+1 -1
drivers/mtd/parsers/redboot.c
··· 102 102 offset -= master->erasesize; 103 103 } 104 104 } else { 105 - offset = directory * master->erasesize; 105 + offset = (unsigned long) directory * master->erasesize; 106 106 while (mtd_block_isbad(master, offset)) { 107 107 offset += master->erasesize; 108 108 if (offset == master->size)