9
0
Fork 0

devfs: don't erase past the end of the partition

"erase /dev/myflash0.mypart 0xf0000+0xf0000" could erase past
the end of the partition.

Signed-off-by: Johannes Stezenbach <js@sig21.net>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
This commit is contained in:
Johannes Stezenbach 2012-06-06 18:04:59 +02:00 committed by Sascha Hauer
parent 9c865c1669
commit 79f9683b8e
1 changed files with 3 additions and 0 deletions

View File

@ -73,6 +73,9 @@ static int devfs_erase(struct device_d *_dev, FILE *f, size_t count, unsigned lo
if (!cdev->ops->erase)
return -ENOSYS;
if (count + offset > cdev->size)
count = cdev->size - offset;
return cdev->ops->erase(cdev, count, offset + cdev->offset);
}