mirror of
https://github.com/adulau/aha.git
synced 2024-12-29 12:16:20 +00:00
[MTD][MTDPART] Fix a division by zero bug
When detecting a partition beyond the end of the device, skip most of the initialisation, in particular those bits causing a division by zero. Signed-off-by: Jörn Engel <joern@logfs.org> Signed-off-by: Atsushi Nemoto <anemo@mba.ocn.ne.jp> Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
This commit is contained in:
parent
6910c13681
commit
f636ffb420
1 changed files with 3 additions and 1 deletions
|
@ -416,6 +416,7 @@ static struct mtd_part *add_one_partition(struct mtd_info *master,
|
|||
slave->mtd.size = 0;
|
||||
printk(KERN_ERR"mtd: partition \"%s\" is out of reach -- disabled\n",
|
||||
part->name);
|
||||
goto out_register;
|
||||
}
|
||||
if (slave->offset + slave->mtd.size > master->size) {
|
||||
slave->mtd.size = master->size - slave->offset;
|
||||
|
@ -475,6 +476,7 @@ static struct mtd_part *add_one_partition(struct mtd_info *master,
|
|||
}
|
||||
}
|
||||
|
||||
out_register:
|
||||
if (part->mtdp) {
|
||||
/* store the object pointer (caller may or may not register it*/
|
||||
*part->mtdp = &slave->mtd;
|
||||
|
|
Loading…
Reference in a new issue