summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTanya Brokhman <tlinder@codeaurora.org>2014-04-01 11:01:12 +0300
committerSascha Hauer <s.hauer@pengutronix.de>2014-09-11 15:53:25 +0200
commitd8c4628977332edb57350d14919019acc2f6114f (patch)
tree176dc2836f77fecf1bb443b0a5f61b741e8f6f57
parenteaa73bfe0269554bf16697b1997475d9d738b290 (diff)
downloadbarebox-d8c4628977332edb57350d14919019acc2f6114f.tar.gz
barebox-d8c4628977332edb57350d14919019acc2f6114f.tar.xz
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>
-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 c083cac58b..4ecbe1838e 100644
--- a/drivers/mtd/ubi/wl.c
+++ b/drivers/mtd/ubi/wl.c
@@ -646,6 +646,9 @@ int ubi_wl_get_peb(struct ubi_device *ubi)
peb = __wl_get_peb(ubi);
+ if (peb < 0)
+ return peb;
+
err = ubi_self_check_all_ff(ubi, peb, ubi->vid_hdr_aloffset,
ubi->peb_size - ubi->vid_hdr_aloffset);
if (err) {