public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] UBI: fastmap: fix a mem leak on error path
@ 2013-09-27 15:37 Richard Genoud
  2013-09-27 19:44 ` Richard Weinberger
  0 siblings, 1 reply; 2+ messages in thread
From: Richard Genoud @ 2013-09-27 15:37 UTC (permalink / raw)
  To: Richard Weinberger, Artem Bityutskiy
  Cc: David Woodhouse, linux-mtd, linux-kernel, Richard Genoud

If the scan_pool() function fails, the "free" list is not freed.
This leads to destroy_ai(ai) complaining with:
"kmem_cache_destroy ubi_ainf_peb_slab: Slab cache still has objects"

Signed-off-by: Richard Genoud <richard.genoud@gmail.com>
---
 drivers/mtd/ubi/fastmap.c |    4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/mtd/ubi/fastmap.c b/drivers/mtd/ubi/fastmap.c
index 05067f5..22eb527 100644
--- a/drivers/mtd/ubi/fastmap.c
+++ b/drivers/mtd/ubi/fastmap.c
@@ -841,6 +841,10 @@ static int ubi_attach_fastmap(struct ubi_device *ubi,
 fail_bad:
 	ret = UBI_BAD_FASTMAP;
 fail:
+	list_for_each_entry_safe(tmp_aeb, _tmp_aeb, &free, u.list) {
+		kmem_cache_free(ai->aeb_slab_cache, tmp_aeb);
+		list_del(&tmp_aeb->u.list);
+	}
 	return ret;
 }
 
-- 
1.7.10.4


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

end of thread, other threads:[~2013-09-27 19:44 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-09-27 15:37 [PATCH] UBI: fastmap: fix a mem leak on error path Richard Genoud
2013-09-27 19:44 ` Richard Weinberger

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