summaryrefslogtreecommitdiffstats
path: root/drivers/mtd/ubi
diff options
context:
space:
mode:
authorRichard Weinberger <richard@nod.at>2013-09-28 15:55:15 +0200
committerArtem Bityutskiy <artem.bityutskiy@linux.intel.com>2013-10-03 19:42:50 +0300
commitfe24c6e5f51ec5ea42d432f67618a084047a23ed (patch)
treee11b37d53afb20b075cb85f8fa1546c86b21d0d9 /drivers/mtd/ubi
parent55b80c409a1368b8dff3c78943101bccb0ea3aa1 (diff)
downloadblackbird-op-linux-fe24c6e5f51ec5ea42d432f67618a084047a23ed.tar.gz
blackbird-op-linux-fe24c6e5f51ec5ea42d432f67618a084047a23ed.zip
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,
fail_bad:
ret = UBI_BAD_FASTMAP;
fail:
+ list_for_each_entry_safe(tmp_aeb, _tmp_aeb, &used, u.list) {
+ kmem_cache_free(ai->aeb_slab_cache, tmp_aeb);
+ list_del(&tmp_aeb->u.list);
+ }
+ list_for_each_entry_safe(tmp_aeb, _tmp_aeb, &eba_orphans, u.list) {
+ kmem_cache_free(ai->aeb_slab_cache, tmp_aeb);
+ list_del(&tmp_aeb->u.list);
+ }
+ 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;
}
OpenPOWER on IntegriCloud