[PATCH 1/2] mtdpart: Avoid divide-by-zero on out-of-reach path

Atsushi Nemoto anemo at mba.ocn.ne.jp
Tue Jun 17 12:15:40 EDT 2008


On Tue, 17 Jun 2008 17:39:43 +0200, Jörn Engel <joern at logfs.org> wrote:
> > In other words, I am tempted to replace all that with a single line:
> > 	BUG();
> 
> Or maybe combine it with the else path:
> 	slave->mtd.erasesize = master->erasesize;
> 	if (master->numeraseregions > 1)
> 		printk(KERN_ERR"mtdpart can not handle multiple eraseregions correctly.\n");
> 
> Nemoto-san, would this be good enough for you?  It fixes the bug you
> noticed, it removes most long lines and it removes the sparse warning.
> It also removes functionality that may have been useful to some person -
> detecting a smaller erasesize.  And with some luck and a warm easterly
> wind, that functionality may even have worked.

No, unfortunately.  For example, if you split a 2MB chip with
16KB+8KB+8KB+32KB+64KBx31 eraseregions into two 1MB partitions, both
partition should have 64KB erase size.

---
Atsushi Nemoto



More information about the linux-mtd mailing list