Skip to content

Commit

Permalink
UBI: check if we are in RO mode in the erase routine
Browse files Browse the repository at this point in the history
'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>
  • Loading branch information
Artem Bityutskiy authored and Artem Bityutskiy committed Apr 5, 2011
1 parent 7da6443 commit 3efe509
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion drivers/mtd/ubi/io.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -390,7 +396,7 @@ static int do_sync_erase(struct ubi_device *ubi, int pnum)
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;
}
Expand Down

0 comments on commit 3efe509

Please sign in to comment.