aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd/ubi
diff options
context:
space:
mode:
authorRichard Weinberger <richard@nod.at>2013-09-28 09:55:15 -0400
committerArtem Bityutskiy <artem.bityutskiy@linux.intel.com>2013-10-03 12:42:50 -0400
commitfe24c6e5f51ec5ea42d432f67618a084047a23ed (patch)
treee11b37d53afb20b075cb85f8fa1546c86b21d0d9 /drivers/mtd/ubi
parent55b80c409a1368b8dff3c78943101bccb0ea3aa1 (diff)
UBI: Fix memory leak in ubi_attach_fastmap() error path
On error we have to free all three temporary lists. Reported-by: Richard Genoud <richard.genoud@gmail.com> Signed-off-by: Richard Weinberger <richard@nod.at> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Diffstat (limited to 'drivers/mtd/ubi')
-rw-r--r--drivers/mtd/ubi/fastmap.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/drivers/mtd/ubi/fastmap.c b/drivers/mtd/ubi/fastmap.c
index 05067f522476..4cfc8da27221 100644
--- a/drivers/mtd/ubi/fastmap.c
+++ b/drivers/mtd/ubi/fastmap.c
@@ -841,6 +841,19 @@ static int ubi_attach_fastmap(struct ubi_device *ubi,
841fail_bad: 841fail_bad:
842 ret = UBI_BAD_FASTMAP; 842 ret = UBI_BAD_FASTMAP;
843fail: 843fail:
844 list_for_each_entry_safe(tmp_aeb, _tmp_aeb, &used, u.list) {
845 kmem_cache_free(ai->aeb_slab_cache, tmp_aeb);
846 list_del(&tmp_aeb->u.list);
847 }
848 list_for_each_entry_safe(tmp_aeb, _tmp_aeb, &eba_orphans, u.list) {
849 kmem_cache_free(ai->aeb_slab_cache, tmp_aeb);
850 list_del(&tmp_aeb->u.list);
851 }
852 list_for_each_entry_safe(tmp_aeb, _tmp_aeb, &free, u.list) {
853 kmem_cache_free(ai->aeb_slab_cache, tmp_aeb);
854 list_del(&tmp_aeb->u.list);
855 }
856
844 return ret; 857 return ret;
845} 858}
846 859