summaryrefslogtreecommitdiff
path: root/drivers/mtd/ubi
diff options
context:
space:
mode:
authorArtem Bityutskiy <Artem.Bityutskiy@nokia.com>2011-03-18 18:11:42 +0200
committerArtem Bityutskiy <Artem.Bityutskiy@nokia.com>2011-04-05 11:08:58 +0300
commit3efe509070e3d27e6d5dbc4bf8588e9453e9b949 (patch)
treed383315c70461be6e6366c6e8142db95e113a12b /drivers/mtd/ubi
parent7da6443aca9be29c6948dcbd636ad50154d0bc0c (diff)
UBI: check if we are in RO mode in the erase routine
'do_sync_erase()' has to check whether we are in R/O mode before erasing the PEB. This patch adds the check and while on it, adds an assertion which validates the 'pnum' argument, as well as removes a check which is always true because it has already been done few lines before. Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Diffstat (limited to 'drivers/mtd/ubi')
-rw-r--r--drivers/mtd/ubi/io.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/drivers/mtd/ubi/io.c b/drivers/mtd/ubi/io.c
index eededf94f5a6..e347cc4388ed 100644
--- a/drivers/mtd/ubi/io.c
+++ b/drivers/mtd/ubi/io.c
@@ -344,6 +344,12 @@ static int do_sync_erase(struct ubi_device *ubi, int pnum)
wait_queue_head_t wq;
dbg_io("erase PEB %d", pnum);
+ ubi_assert(pnum >= 0 && pnum < ubi->peb_count);
+
+ if (ubi->ro_mode) {
+ ubi_err("read-only mode");
+ return -EROFS;
+ }
retry:
init_waitqueue_head(&wq);
@@ -390,7 +396,7 @@ retry:
if (err)
return err;
- if (ubi_dbg_is_erase_failure() && !err) {
+ if (ubi_dbg_is_erase_failure()) {
dbg_err("cannot erase PEB %d (emulated)", pnum);
return -EIO;
}