aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd/ubi/wl.c
diff options
context:
space:
mode:
authorTanya Brokhman <tlinder@codeaurora.org>2014-04-01 04:01:12 -0400
committerArtem Bityutskiy <artem.bityutskiy@linux.intel.com>2014-05-05 02:31:33 -0400
commit87ed89d21ede38f86be9419ca7c6dd4761764bbb (patch)
tree465df391e8858ae8575a2bf72815e4302ab83386 /drivers/mtd/ubi/wl.c
parentfcdd57c8902a936a616df2066d873b38ef3ed364 (diff)
UBI: fix error path in __wl_get_peb
In case of an error (if there are not free PEB's for example), __wl_get_peb will return a negative value. In order to prevent access violation we need to test the returned value prior to using it later on. Signed-off-by: Tatyana Brokhman <tlinder@codeaurora.org> Reviewed-by: Dolev Raviv <draviv@codeaurora.org> Acked-by: Richard Weinberger <richard@nod.at> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Diffstat (limited to 'drivers/mtd/ubi/wl.c')
-rw-r--r--drivers/mtd/ubi/wl.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/drivers/mtd/ubi/wl.c b/drivers/mtd/ubi/wl.c
index 02317c1c0238..457ead32105c 100644
--- a/drivers/mtd/ubi/wl.c
+++ b/drivers/mtd/ubi/wl.c
@@ -684,6 +684,9 @@ int ubi_wl_get_peb(struct ubi_device *ubi)
684 peb = __wl_get_peb(ubi); 684 peb = __wl_get_peb(ubi);
685 spin_unlock(&ubi->wl_lock); 685 spin_unlock(&ubi->wl_lock);
686 686
687 if (peb < 0)
688 return peb;
689
687 err = ubi_self_check_all_ff(ubi, peb, ubi->vid_hdr_aloffset, 690 err = ubi_self_check_all_ff(ubi, peb, ubi->vid_hdr_aloffset,
688 ubi->peb_size - ubi->vid_hdr_aloffset); 691 ubi->peb_size - ubi->vid_hdr_aloffset);
689 if (err) { 692 if (err) {