* [PATCH] UBI: Fix double free after do_sync_erase()
@ 2014-11-06 15:47 Richard Weinberger
2014-11-07 11:50 ` Artem Bityutskiy
0 siblings, 1 reply; 3+ messages in thread
From: Richard Weinberger @ 2014-11-06 15:47 UTC (permalink / raw)
To: dedekind1; +Cc: linux-mtd, linux-kernel, Richard Weinberger, stable
If the erase worker is unable to erase a PEB it will
free the ubi_wl_entry itself.
The failing ubi_wl_entry must not free()'d again after
do_sync_erase() returns.
Cc: <stable@vger.kernel.org>
Signed-off-by: Richard Weinberger <richard@nod.at>
---
drivers/mtd/ubi/wl.c | 10 +++-------
1 file changed, 3 insertions(+), 7 deletions(-)
diff --git a/drivers/mtd/ubi/wl.c b/drivers/mtd/ubi/wl.c
index 6654f191..b9686c1 100644
--- a/drivers/mtd/ubi/wl.c
+++ b/drivers/mtd/ubi/wl.c
@@ -1212,7 +1212,6 @@ static int wear_leveling_worker(struct ubi_device *ubi, struct ubi_work *wrk,
err = do_sync_erase(ubi, e1, vol_id, lnum, 0);
if (err) {
- kmem_cache_free(ubi_wl_entry_slab, e1);
if (e2)
kmem_cache_free(ubi_wl_entry_slab, e2);
goto out_ro;
@@ -1226,10 +1225,8 @@ static int wear_leveling_worker(struct ubi_device *ubi, struct ubi_work *wrk,
dbg_wl("PEB %d (LEB %d:%d) was put meanwhile, erase",
e2->pnum, vol_id, lnum);
err = do_sync_erase(ubi, e2, vol_id, lnum, 0);
- if (err) {
- kmem_cache_free(ubi_wl_entry_slab, e2);
+ if (err)
goto out_ro;
- }
}
dbg_wl("done");
@@ -1265,10 +1262,9 @@ out_not_moved:
ubi_free_vid_hdr(ubi, vid_hdr);
err = do_sync_erase(ubi, e2, vol_id, lnum, torture);
- if (err) {
- kmem_cache_free(ubi_wl_entry_slab, e2);
+ if (err)
goto out_ro;
- }
+
mutex_unlock(&ubi->move_mutex);
return 0;
--
2.1.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] UBI: Fix double free after do_sync_erase()
2014-11-06 15:47 [PATCH] UBI: Fix double free after do_sync_erase() Richard Weinberger
@ 2014-11-07 11:50 ` Artem Bityutskiy
2014-11-07 11:53 ` Richard Weinberger
0 siblings, 1 reply; 3+ messages in thread
From: Artem Bityutskiy @ 2014-11-07 11:50 UTC (permalink / raw)
To: Richard Weinberger; +Cc: linux-mtd, linux-kernel, stable
On Thu, 2014-11-06 at 16:47 +0100, Richard Weinberger wrote:
> If the erase worker is unable to erase a PEB it will
> free the ubi_wl_entry itself.
> The failing ubi_wl_entry must not free()'d again after
> do_sync_erase() returns.
>
> Cc: <stable@vger.kernel.org>
> Signed-off-by: Richard Weinberger <richard@nod.at>
Pushed, thanks!
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] UBI: Fix double free after do_sync_erase()
2014-11-07 11:50 ` Artem Bityutskiy
@ 2014-11-07 11:53 ` Richard Weinberger
0 siblings, 0 replies; 3+ messages in thread
From: Richard Weinberger @ 2014-11-07 11:53 UTC (permalink / raw)
To: dedekind1; +Cc: linux-mtd, linux-kernel, stable
Am 07.11.2014 um 12:50 schrieb Artem Bityutskiy:
> On Thu, 2014-11-06 at 16:47 +0100, Richard Weinberger wrote:
>> If the erase worker is unable to erase a PEB it will
>> free the ubi_wl_entry itself.
>> The failing ubi_wl_entry must not free()'d again after
>> do_sync_erase() returns.
>>
>> Cc: <stable@vger.kernel.org>
>> Signed-off-by: Richard Weinberger <richard@nod.at>
>
> Pushed, thanks!
BTW: Please don't forget "[PATCH] UBI: Fix invalid vfree()".
Thanks,
//richard
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2014-11-07 11:53 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-11-06 15:47 [PATCH] UBI: Fix double free after do_sync_erase() Richard Weinberger
2014-11-07 11:50 ` Artem Bityutskiy
2014-11-07 11:53 ` Richard Weinberger
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).