diff --git a/drivers/mtd/ubi/eba.c b/drivers/mtd/ubi/eba.c index 7fbe0d7..289c003 100644 --- a/drivers/mtd/ubi/eba.c +++ b/drivers/mtd/ubi/eba.c @@ -367,6 +367,7 @@ out_unlock: * returned for any volume type if an ECC error was detected by the MTD device * driver. Other negative error cored may be returned in case of other errors. */ +int in_wl_tree(struct ubi_wl_entry *e, struct rb_root *root); int ubi_eba_read_leb(struct ubi_device *ubi, struct ubi_volume *vol, int lnum, void *buf, int offset, int len, int check) { @@ -392,6 +393,19 @@ int ubi_eba_read_leb(struct ubi_device *ubi, struct ubi_volume *vol, int lnum, memset(buf, 0xFF, len); return 0; } + { + struct ubi_wl_entry *e; + int bad; + + spin_lock(&ubi->wl_lock); + e = ubi->lookuptbl[pnum]; + bad = in_wl_tree(e, &ubi->erroneous); + spin_unlock(&ubi->wl_lock); + /* we should not append to read bad block */ + if (bad) { + return -EBADMSG; + } + } dbg_eba("read %d bytes from offset %d of LEB %d:%d, PEB %d", len, offset, vol_id, lnum, pnum); diff --git a/drivers/mtd/ubi/wl.c b/drivers/mtd/ubi/wl.c index 10b6100..3c4c3ed 100644 --- a/drivers/mtd/ubi/wl.c +++ b/drivers/mtd/ubi/wl.c @@ -292,7 +292,7 @@ static int produce_free_peb(struct ubi_device *ubi) * This function returns non-zero if @e is in the @root RB-tree and zero if it * is not. */ -static int in_wl_tree(struct ubi_wl_entry *e, struct rb_root *root) +/*static */int in_wl_tree(struct ubi_wl_entry *e, struct rb_root *root) { struct rb_node *p;