|
@@ -160,8 +160,12 @@ static ssize_t mtdchar_read(struct file *file, char __user *buf, size_t count,
|
|
|
|
|
|
pr_debug("MTD_read\n");
|
|
|
|
|
|
- if (*ppos + count > mtd->size)
|
|
|
- count = mtd->size - *ppos;
|
|
|
+ if (*ppos + count > mtd->size) {
|
|
|
+ if (*ppos < mtd->size)
|
|
|
+ count = mtd->size - *ppos;
|
|
|
+ else
|
|
|
+ count = 0;
|
|
|
+ }
|
|
|
|
|
|
if (!count)
|
|
|
return 0;
|
|
@@ -246,7 +250,7 @@ static ssize_t mtdchar_write(struct file *file, const char __user *buf, size_t c
|
|
|
|
|
|
pr_debug("MTD_write\n");
|
|
|
|
|
|
- if (*ppos == mtd->size)
|
|
|
+ if (*ppos >= mtd->size)
|
|
|
return -ENOSPC;
|
|
|
|
|
|
if (*ppos + count > mtd->size)
|