public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
* [PATCH] UBI: fix a horrible memory deallocation bug
@ 2012-09-03 14:25 Artem Bityutskiy
  2012-09-03 14:43 ` Richard Genoud
  0 siblings, 1 reply; 2+ messages in thread
From: Artem Bityutskiy @ 2012-09-03 14:25 UTC (permalink / raw)
  To: Richard Genoud; +Cc: MTD Maling List

From: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>

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>
Cc: stable@vger.kernel.org [v2.6.39+]
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
---
 drivers/mtd/ubi/vtbl.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/mtd/ubi/vtbl.c b/drivers/mtd/ubi/vtbl.c
index 64b9c56..926e3df 100644
--- a/drivers/mtd/ubi/vtbl.c
+++ b/drivers/mtd/ubi/vtbl.c
@@ -340,7 +340,7 @@ retry:
 	 * of this LEB as it will be deleted and freed in 'ubi_add_to_av()'.
 	 */
 	err = ubi_add_to_av(ubi, ai, new_aeb->pnum, new_aeb->ec, vid_hdr, 0);
-	kfree(new_aeb);
+	kmem_cache_free(ai->aeb_slab_cache, new_aeb);
 	ubi_free_vid_hdr(ubi, vid_hdr);
 	return err;
 
@@ -353,7 +353,7 @@ write_error:
 		list_add(&new_aeb->u.list, &ai->erase);
 		goto retry;
 	}
-	kfree(new_aeb);
+	kmem_cache_free(ai->aeb_slab_cache, new_aeb);
 out_free:
 	ubi_free_vid_hdr(ubi, vid_hdr);
 	return err;
-- 
1.7.7.6

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] UBI: fix a horrible memory deallocation bug
  2012-09-03 14:25 [PATCH] UBI: fix a horrible memory deallocation bug Artem Bityutskiy
@ 2012-09-03 14:43 ` Richard Genoud
  0 siblings, 0 replies; 2+ messages in thread
From: Richard Genoud @ 2012-09-03 14:43 UTC (permalink / raw)
  To: Artem Bityutskiy; +Cc: MTD Maling List

2012/9/3 Artem Bityutskiy <dedekind1@gmail.com>:
> From: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
>
> 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>
> Cc: stable@vger.kernel.org [v2.6.39+]
> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
> ---
>  drivers/mtd/ubi/vtbl.c |    4 ++--
>  1 files changed, 2 insertions(+), 2 deletions(-)
Tested ok, works like a charm !
Thanks !

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-09-03 14:44 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-09-03 14:25 [PATCH] UBI: fix a horrible memory deallocation bug Artem Bityutskiy
2012-09-03 14:43 ` Richard Genoud

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox