[PATCH 04/10] UBI: fix error path in __wl_get_peb

Sascha Hauer s.hauer at pengutronix.de
Thu Sep 11 08:16:04 PDT 2014


From: Tanya Brokhman <tlinder at codeaurora.org>

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 at codeaurora.org>
Reviewed-by: Dolev Raviv <draviv at codeaurora.org>
Acked-by: Richard Weinberger <richard at nod.at>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy at linux.intel.com>
---
 drivers/mtd/ubi/wl.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/mtd/ubi/wl.c b/drivers/mtd/ubi/wl.c
index c083cac..4ecbe18 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) {
-- 
2.1.0




More information about the barebox mailing list