linux-mtd.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [RFC/PATCH] mtd: ubi: Test return value of __wl_get_peb
@ 2014-04-01  8:01 Tanya Brokhman
  2014-04-07  5:22 ` Dolev Raviv
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Tanya Brokhman @ 2014-04-01  8:01 UTC (permalink / raw)
  To: dedekind1; +Cc: linux-mtd, open list, Tanya Brokhman

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>

diff --git a/drivers/mtd/ubi/wl.c b/drivers/mtd/ubi/wl.c
index 02317c1..457ead3 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)
 	peb = __wl_get_peb(ubi);
 	spin_unlock(&ubi->wl_lock);
 
+	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) {
-- 
1.7.6
-- 
QUALCOMM ISRAEL, on behalf of Qualcomm Innovation Center, Inc. is a member
of Code Aurora Forum, hosted by The Linux Foundation

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* RE: [RFC/PATCH] mtd: ubi: Test return value of __wl_get_peb
  2014-04-01  8:01 [RFC/PATCH] mtd: ubi: Test return value of __wl_get_peb Tanya Brokhman
@ 2014-04-07  5:22 ` Dolev Raviv
  2014-04-07 13:14 ` Richard Weinberger
  2014-04-08 13:44 ` Artem Bityutskiy
  2 siblings, 0 replies; 4+ messages in thread
From: Dolev Raviv @ 2014-04-07  5:22 UTC (permalink / raw)
  To: 'Tanya Brokhman', dedekind1; +Cc: linux-mtd, 'open list'

Reviewed-by: Dolev Raviv <draviv@codeaurora.org>

Thanks,
Dolev
-- 
QUALCOMM ISRAEL, on behalf of Qualcomm Innovation Center, Inc. is a member
of Code Aurora Forum, hosted by The Linux Foundation


-----Original Message-----
From: linux-mtd [mailto:linux-mtd-bounces@lists.infradead.org] On Behalf Of
Tanya Brokhman
Sent: Tuesday, April 01, 2014 11:01 AM
To: dedekind1@gmail.com
Cc: linux-mtd@lists.infradead.org; open list; Tanya Brokhman
Subject: [RFC/PATCH] mtd: ubi: Test return value of __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>

diff --git a/drivers/mtd/ubi/wl.c b/drivers/mtd/ubi/wl.c index
02317c1..457ead3 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)
 	peb = __wl_get_peb(ubi);
 	spin_unlock(&ubi->wl_lock);
 
+	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) {
--
1.7.6
--
QUALCOMM ISRAEL, on behalf of Qualcomm Innovation Center, Inc. is a member
of Code Aurora Forum, hosted by The Linux Foundation



______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [RFC/PATCH] mtd: ubi: Test return value of __wl_get_peb
  2014-04-01  8:01 [RFC/PATCH] mtd: ubi: Test return value of __wl_get_peb Tanya Brokhman
  2014-04-07  5:22 ` Dolev Raviv
@ 2014-04-07 13:14 ` Richard Weinberger
  2014-04-08 13:44 ` Artem Bityutskiy
  2 siblings, 0 replies; 4+ messages in thread
From: Richard Weinberger @ 2014-04-07 13:14 UTC (permalink / raw)
  To: Tanya Brokhman; +Cc: linux-mtd@lists.infradead.org, open list, Artem Bityutskiy

On Tue, Apr 1, 2014 at 10:01 AM, Tanya Brokhman <tlinder@codeaurora.org> wrote:
> 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>
>
> diff --git a/drivers/mtd/ubi/wl.c b/drivers/mtd/ubi/wl.c
> index 02317c1..457ead3 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)
>         peb = __wl_get_peb(ubi);
>         spin_unlock(&ubi->wl_lock);
>
> +       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) {

Acked-by: Richard Weinberger <richard@nod.at>

-- 
Thanks,
//richard

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [RFC/PATCH] mtd: ubi: Test return value of __wl_get_peb
  2014-04-01  8:01 [RFC/PATCH] mtd: ubi: Test return value of __wl_get_peb Tanya Brokhman
  2014-04-07  5:22 ` Dolev Raviv
  2014-04-07 13:14 ` Richard Weinberger
@ 2014-04-08 13:44 ` Artem Bityutskiy
  2 siblings, 0 replies; 4+ messages in thread
From: Artem Bityutskiy @ 2014-04-08 13:44 UTC (permalink / raw)
  To: Tanya Brokhman; +Cc: linux-mtd, open list

On Tue, 2014-04-01 at 11:01 +0300, Tanya Brokhman wrote:
> 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>

Pushed to linux-ubifs.git / master, thanks!

-- 
Best Regards,
Artem Bityutskiy

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2014-04-08 13:45 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-04-01  8:01 [RFC/PATCH] mtd: ubi: Test return value of __wl_get_peb Tanya Brokhman
2014-04-07  5:22 ` Dolev Raviv
2014-04-07 13:14 ` Richard Weinberger
2014-04-08 13:44 ` Artem Bityutskiy

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).