]> git.hungrycats.org Git - linux/commitdiff
UBI: fix a horrible memory deallocation bug
authorArtem Bityutskiy <artem.bityutskiy@linux.intel.com>
Wed, 12 Sep 2012 07:05:22 +0000 (09:05 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 2 Oct 2012 17:30:38 +0000 (10:30 -0700)
commit 78b495c39add820ab66ab897af9bd77a5f2e91f6 upstream

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"

Reported-by: Richard Genoud <richard.genoud@gmail.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Signed-off-by: Richard Genoud <richard.genoud@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/mtd/ubi/vtbl.c

index 17cec0c0154448d85271a4422ac8907f9dedc00d..c015fc0a76d8cdb2e6765c22ed4111c4a1d83e7b 100644 (file)
@@ -346,7 +346,7 @@ retry:
         */
        err = ubi_scan_add_used(ubi, si, new_seb->pnum, new_seb->ec,
                                vid_hdr, 0);
-       kfree(new_seb);
+       kmem_cache_free(si->scan_leb_slab, new_seb);
        ubi_free_vid_hdr(ubi, vid_hdr);
        return err;
 
@@ -359,7 +359,7 @@ write_error:
                list_add(&new_seb->u.list, &si->erase);
                goto retry;
        }
-       kfree(new_seb);
+       kmem_cache_free(si->scan_leb_slab, new_seb);
 out_free:
        ubi_free_vid_hdr(ubi, vid_hdr);
        return err;