diff options
| author | Richard Weinberger <richard@nod.at> | 2014-11-06 10:47:49 -0500 |
|---|---|---|
| committer | Artem Bityutskiy <artem.bityutskiy@linux.intel.com> | 2014-11-07 06:42:43 -0500 |
| commit | aa5ad3b6eb8feb2399a5d26c8fb0060561bb9534 (patch) | |
| tree | 02354b3ea14e9d5aad2b543ffc9ea0b320298de0 /drivers | |
| parent | a76284e6f89b2ae37d413fe793752257be01765a (diff) | |
UBI: Fix double free after do_sync_erase()
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>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Diffstat (limited to 'drivers')
| -rw-r--r-- | drivers/mtd/ubi/wl.c | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/drivers/mtd/ubi/wl.c b/drivers/mtd/ubi/wl.c index 7d2a25f96804..834f6fe1f5fa 100644 --- a/drivers/mtd/ubi/wl.c +++ b/drivers/mtd/ubi/wl.c | |||
| @@ -1216,7 +1216,6 @@ static int wear_leveling_worker(struct ubi_device *ubi, struct ubi_work *wrk, | |||
| 1216 | 1216 | ||
| 1217 | err = do_sync_erase(ubi, e1, vol_id, lnum, 0); | 1217 | err = do_sync_erase(ubi, e1, vol_id, lnum, 0); |
| 1218 | if (err) { | 1218 | if (err) { |
| 1219 | kmem_cache_free(ubi_wl_entry_slab, e1); | ||
| 1220 | if (e2) | 1219 | if (e2) |
| 1221 | kmem_cache_free(ubi_wl_entry_slab, e2); | 1220 | kmem_cache_free(ubi_wl_entry_slab, e2); |
| 1222 | goto out_ro; | 1221 | goto out_ro; |
| @@ -1230,10 +1229,8 @@ static int wear_leveling_worker(struct ubi_device *ubi, struct ubi_work *wrk, | |||
| 1230 | dbg_wl("PEB %d (LEB %d:%d) was put meanwhile, erase", | 1229 | dbg_wl("PEB %d (LEB %d:%d) was put meanwhile, erase", |
| 1231 | e2->pnum, vol_id, lnum); | 1230 | e2->pnum, vol_id, lnum); |
| 1232 | err = do_sync_erase(ubi, e2, vol_id, lnum, 0); | 1231 | err = do_sync_erase(ubi, e2, vol_id, lnum, 0); |
| 1233 | if (err) { | 1232 | if (err) |
| 1234 | kmem_cache_free(ubi_wl_entry_slab, e2); | ||
| 1235 | goto out_ro; | 1233 | goto out_ro; |
| 1236 | } | ||
| 1237 | } | 1234 | } |
| 1238 | 1235 | ||
| 1239 | dbg_wl("done"); | 1236 | dbg_wl("done"); |
| @@ -1269,10 +1266,9 @@ out_not_moved: | |||
| 1269 | 1266 | ||
| 1270 | ubi_free_vid_hdr(ubi, vid_hdr); | 1267 | ubi_free_vid_hdr(ubi, vid_hdr); |
| 1271 | err = do_sync_erase(ubi, e2, vol_id, lnum, torture); | 1268 | err = do_sync_erase(ubi, e2, vol_id, lnum, torture); |
| 1272 | if (err) { | 1269 | if (err) |
| 1273 | kmem_cache_free(ubi_wl_entry_slab, e2); | ||
| 1274 | goto out_ro; | 1270 | goto out_ro; |
| 1275 | } | 1271 | |
| 1276 | mutex_unlock(&ubi->move_mutex); | 1272 | mutex_unlock(&ubi->move_mutex); |
| 1277 | return 0; | 1273 | return 0; |
| 1278 | 1274 | ||
