aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd/ubi
diff options
context:
space:
mode:
authorArtem Bityutskiy <artem.bityutskiy@linux.intel.com>2012-09-03 10:12:29 -0400
committerArtem Bityutskiy <artem.bityutskiy@linux.intel.com>2012-09-04 02:40:26 -0400
commit78b495c39add820ab66ab897af9bd77a5f2e91f6 (patch)
tree1117d2f1694290265c3420b3c3c93499091e1b71 /drivers/mtd/ubi
parent4cbe5a555fa58a79b6ecbb6c531b8bab0650778d (diff)
UBI: fix a horrible memory deallocation bug
UBI was mistakingly using 'kfree()' instead of 'kmem_cache_free()' when freeing "attach eraseblock" structures in vtbl.c. Thankfully, this happened only when we were doing auto-format, so many systems were unaffected. However, there are still many users affected. It is strange, but the system did not crash and nothing bad happened when the SLUB memory allocator was used. However, in case of SLOB we observed an crash right away. This problem was introduced in 2.6.39 by commit "6c1e875 UBI: add slab cache for ubi_scan_leb objects" A note for stable trees: Because variable were renamed, this won't cleanly apply to older kernels. Changing names like this should help: 1. ai -> si 2. aeb_slab_cache -> seb_slab_cache 3. new_aeb -> new_seb Reported-by: Richard Genoud <richard.genoud@gmail.com> Tested-by: Richard Genoud <richard.genoud@gmail.com> Tested-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com> Cc: stable@vger.kernel.org [v2.6.39+] Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Diffstat (limited to 'drivers/mtd/ubi')
-rw-r--r--drivers/mtd/ubi/vtbl.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/mtd/ubi/vtbl.c b/drivers/mtd/ubi/vtbl.c
index 437bc193e170..568307cc7caf 100644
--- a/drivers/mtd/ubi/vtbl.c
+++ b/drivers/mtd/ubi/vtbl.c
@@ -340,7 +340,7 @@ retry:
340 * of this LEB as it will be deleted and freed in 'ubi_add_to_av()'. 340 * of this LEB as it will be deleted and freed in 'ubi_add_to_av()'.
341 */ 341 */
342 err = ubi_add_to_av(ubi, ai, new_aeb->pnum, new_aeb->ec, vid_hdr, 0); 342 err = ubi_add_to_av(ubi, ai, new_aeb->pnum, new_aeb->ec, vid_hdr, 0);
343 kfree(new_aeb); 343 kmem_cache_free(ai->aeb_slab_cache, new_aeb);
344 ubi_free_vid_hdr(ubi, vid_hdr); 344 ubi_free_vid_hdr(ubi, vid_hdr);
345 return err; 345 return err;
346 346
@@ -353,7 +353,7 @@ write_error:
353 list_add(&new_aeb->u.list, &ai->erase); 353 list_add(&new_aeb->u.list, &ai->erase);
354 goto retry; 354 goto retry;
355 } 355 }
356 kfree(new_aeb); 356 kmem_cache_free(ai->aeb_slab_cache, new_aeb);
357out_free: 357out_free:
358 ubi_free_vid_hdr(ubi, vid_hdr); 358 ubi_free_vid_hdr(ubi, vid_hdr);
359 return err; 359 return err;