mtd: diskonchip: Cast an operand to prevent potential overflow
Subsystems (3)
PATCH v4 1/1 mtd: diskonchip: Cast an operand to prevent potential overflow
From: Zichen Xie <[email protected]>
There may be a potential integer overflow issue in inftl_partscan(). parts[0].size is defined as "uint64_t" while mtd->erasesize and ip->firstUnit are defined as 32-bit unsigned integer. The result of the calculation will be limited to 32 bits without correct casting.
---
v2: Correct "Fixes" tag.
v3: Shorten subject and adjust commit log wrapping.
v4: Add Cc tag.
--- drivers/mtd/nand/raw/diskonchip.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mtd/nand/raw/diskonchip.c +1 -1
@@ -1098,7 +1098,7 @@ static inline int __init inftl_partscan(struct mtd_info *mtd, struct mtd_partiti (i == 0) && (ip->firstUnit > 0)) { parts[0 ].name =" DiskOnChip IPL / Media Header partition" ; parts[0 ].offset =0 ; - parts[0 ].size = mtd->erasesize * ip->firstUnit; + parts[0 ].size = (uint64_t )mtd->erasesize * ip->firstUnit; numparts =1 ; }
Signature · 1 line
2.34.1
Quoted 6 lines · Gax-c
There may be a potential integer overflow issue in
inftl_partscan(). parts[0].size is defined as "uint64_t" whilemtd->erasesizeandip->firstUnitare defined as 32-bit unsigned integer. The result of the calculation will be limited to 32 bits without correct casting.
Applied to mtd/fixes, thanks!
[1/1] mtd: diskonchip: Cast an operand to prevent potential overflow
Patche(s) will be available within hours on:
mtd/linux.git
Kind regards,
Miquèl