[MTD] CHIPS: Do not oops when configured flash size is less then chip size My kernel oopsed when the on-board flash chips where quadruple the size of the platform default physmap_map.size. Turned out that max_chips becomes zero, resulting in an oops later in locking chip->mutex being non-initialized. Full debug trace available. Signed-off-by: Leon Woestenberg diff --git a/drivers/mtd/chips/gen_probe.c b/drivers/mtd/chips/gen_probe.c index 9b252d2..9b7f82b 100644 --- a/drivers/mtd/chips/gen_probe.c +++ b/drivers/mtd/chips/gen_probe.c @@ -100,6 +100,11 @@ #endif * Align bitmap storage size to full byte. */ max_chips = map->size >> cfi.chipshift; + if (max_chips == 0) { + printk(KERN_WARNING "Single flash chip size exceeds the configured flash area size. Check your kernel configuration.\n"); + kfree(cfi.cfiq); + return NULL; + } mapsize = (max_chips / 8) + ((max_chips % 8) ? 1 : 0); chip_map = kmalloc(mapsize, GFP_KERNEL); if (!chip_map) {