[PATCH 1/2] m25p80: add additional sanity checks for erasure

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This guards for the cases where the initial offset or byte count is
not aligned with regard to erase block size, thus making it impossible
for erase to do any harm to the nearby sectors.

Signed-off-by: Paul Fertser <fercerpav@xxxxxxxxx>
---
 drivers/nor/m25p80.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/drivers/nor/m25p80.c b/drivers/nor/m25p80.c
index e6fe75e..6f650a5 100644
--- a/drivers/nor/m25p80.c
+++ b/drivers/nor/m25p80.c
@@ -206,7 +206,9 @@ static ssize_t m25p80_erase(struct cdev *cdev, size_t count, unsigned long offse
 		__func__, "at", (long long)offset, (long long)count);
 
 	/* sanity checks */
-	if (offset + count > flash->size)
+	if ((offset + count > flash->size) ||
+	    (offset % flash->erasesize) ||
+	    ((offset+count) % flash->erasesize))
 		return -EINVAL;
 
 	addr = offset;
-- 
1.7.2.3


_______________________________________________
barebox mailing list
barebox@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/barebox


[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux