mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: barebox@lists.infradead.org
Subject: [PATCH 04/10] UBI: fix error path in __wl_get_peb
Date: Thu, 11 Sep 2014 17:16:04 +0200	[thread overview]
Message-ID: <1410448570-2054-5-git-send-email-s.hauer@pengutronix.de> (raw)
In-Reply-To: <1410448570-2054-1-git-send-email-s.hauer@pengutronix.de>

From: Tanya Brokhman <tlinder@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@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>
---
 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


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  parent reply	other threads:[~2014-09-11 15:16 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-11 15:16 UBI patches Sascha Hauer
2014-09-11 15:16 ` [PATCH 01/10] UBI: fix error return code Sascha Hauer
2014-09-11 15:16 ` [PATCH 02/10] UBI: avoid program operation on NOR flash after erasure interrupted Sascha Hauer
2014-09-11 15:16 ` [PATCH 03/10] UBI: fix some use after free bugs Sascha Hauer
2014-09-11 15:16 ` Sascha Hauer [this message]
2014-09-11 15:16 ` [PATCH 05/10] UBI: fix ubi free PEBs count calculation Sascha Hauer
2014-09-11 15:16 ` [PATCH 06/10] UBI: fix rb_tree node comparison in add_map Sascha Hauer
2014-09-11 15:16 ` [PATCH 07/10] UBI: fix the volumes tree sorting criteria Sascha Hauer
2014-09-11 15:16 ` [PATCH 08/10] UBI: fastmap: do not miss bit-flips Sascha Hauer
2014-09-11 15:16 ` [PATCH 09/10] UBI: init_volumes: Ignore volumes with no LEBs Sascha Hauer
2014-09-11 15:16 ` [PATCH 10/10] UBI: bugfix in ubi_wl_flush() Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1410448570-2054-5-git-send-email-s.hauer@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox