UBI: Fix double free after do_sync_erase()
commit aa5ad3b6eb upstream.
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.
Signed-off-by: Richard Weinberger <richard@nod.at>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
398dd8fd97
commit
ccebbb7e53
1 changed files with 3 additions and 7 deletions
|
|
@ -1209,7 +1209,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;
|
||||
|
|
@ -1223,10 +1222,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");
|
||||
|
|
@ -1262,10 +1259,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;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue