summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2009-12-02 17:58:12 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2009-12-03 11:12:51 +0100
commit2c84734970cd012ee6a417adc8f4e8936ee2e86c (patch)
treec2e75af8afc56a47300fdf0e39dc6e442299a784
parent74d14b746d94ff36f67c7e3ea19977f6ee7d5912 (diff)
downloadbarebox-2c84734970cd012ee6a417adc8f4e8936ee2e86c.tar.gz
barebox-2c84734970cd012ee6a417adc8f4e8936ee2e86c.tar.xz
nand: refuse to write data if not beginning on a page boundary
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
-rw-r--r--drivers/nand/nand.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/drivers/nand/nand.c b/drivers/nand/nand.c
index a058df2f63..f79f7c370f 100644
--- a/drivers/nand/nand.c
+++ b/drivers/nand/nand.c
@@ -58,12 +58,17 @@ static ssize_t nand_write(struct cdev* cdev, const void *buf, size_t _count, ulo
void *wrbuf = NULL;
size_t count = _count;
+ if (NOTALIGNED(offset)) {
+ printf("offset 0x%08x not page aligned\n", offset);
+ return -EINVAL;
+ }
+
debug("write: 0x%08x 0x%08x\n", offset, count);
while (count) {
now = count > info->writesize ? info->writesize : count;
- if (NOTALIGNED(now) || NOTALIGNED(offset)) {
+ if (NOTALIGNED(now)) {
debug("not aligned: %d %d\n", info->writesize, (offset % info->writesize));
wrbuf = xmalloc(info->writesize);
memset(wrbuf, 0xff, info->writesize);