Skip to content

Commit 3884f03

Browse files
baruchsiachmiquelraynal
authored andcommitted
mtd: maps: physmap-core: fix flash size larger than 32-bit
mtd-ram can potentially be larger than 4GB. get_bitmask_order() uses fls() that is not guaranteed to work with values larger than 32-bit. Specifically on aarch64 fls() returns 0 when all 32 LSB bits are clear. Use fls64() instead. Fixes: ba32ce9 ("mtd: maps: Merge gpio-addr-flash.c into physmap-core.c") Signed-off-by: Baruch Siach <baruch@tkos.co.il> Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com> Link: https://lore.kernel.org/linux-mtd/9fbf3664ce00f8b07867f1011834015f21d162a5.1707388458.git.baruch@tkos.co.il
1 parent 18af7e3 commit 3884f03

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/mtd/maps/physmap-core.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -518,7 +518,7 @@ static int physmap_flash_probe(struct platform_device *dev)
518518
if (!info->maps[i].phys)
519519
info->maps[i].phys = res->start;
520520

521-
info->win_order = get_bitmask_order(resource_size(res)) - 1;
521+
info->win_order = fls64(resource_size(res)) - 1;
522522
info->maps[i].size = BIT(info->win_order +
523523
(info->gpios ?
524524
info->gpios->ndescs : 0));

0 commit comments

Comments
 (0)