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:
parent
9c865c1669
commit
79f9683b8e
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue