mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH 1/2] m25p80: add additional sanity checks for erasure
@ 2011-09-15 11:27 Paul Fertser
  2011-09-15 11:31 ` [PATCH 2/2] m25p80: use proper erasesize for SECT_4K devices Paul Fertser
  2011-09-20 19:31 ` [PATCH 1/2] m25p80: add additional sanity checks for erasure Sascha Hauer
  0 siblings, 2 replies; 5+ messages in thread
From: Paul Fertser @ 2011-09-15 11:27 UTC (permalink / raw)
  To: barebox; +Cc: Franck JULLIEN

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@gmail.com>
---
 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@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2011-09-29 10:28 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-09-15 11:27 [PATCH 1/2] m25p80: add additional sanity checks for erasure Paul Fertser
2011-09-15 11:31 ` [PATCH 2/2] m25p80: use proper erasesize for SECT_4K devices Paul Fertser
2011-09-20 19:31 ` [PATCH 1/2] m25p80: add additional sanity checks for erasure Sascha Hauer
2011-09-20 20:29   ` Paul Fertser
2011-09-29 10:28     ` Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox