2014-04-01 08:01:30

by Tanya Brokhman

[permalink] [raw]
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 <[email protected]>

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


2014-04-07 05:22:18

by Dolev Raviv

[permalink] [raw]
Subject: RE: [RFC/PATCH] mtd: ubi: Test return value of __wl_get_peb

Reviewed-by: Dolev Raviv <[email protected]>

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:[email protected]] On Behalf Of
Tanya Brokhman
Sent: Tuesday, April 01, 2014 11:01 AM
To: [email protected]
Cc: [email protected]; 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 <[email protected]>

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/

2014-04-07 13:14:08

by Richard Weinberger

[permalink] [raw]
Subject: Re: [RFC/PATCH] mtd: ubi: Test return value of __wl_get_peb

On Tue, Apr 1, 2014 at 10:01 AM, Tanya Brokhman <[email protected]> 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 <[email protected]>
>
> 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 <[email protected]>

--
Thanks,
//richard

2014-04-08 13:47:51

by Artem Bityutskiy

[permalink] [raw]
Subject: Re: [RFC/PATCH] mtd: ubi: Test return value of __wl_get_peb

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 <[email protected]>

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

--
Best Regards,
Artem Bityutskiy