Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit fe24c6e5 authored by Richard Weinberger's avatar Richard Weinberger Committed by Artem Bityutskiy
Browse files

UBI: Fix memory leak in ubi_attach_fastmap() error path



On error we have to free all three temporary lists.

Reported-by: default avatarRichard Genoud <richard.genoud@gmail.com>
Signed-off-by: default avatarRichard Weinberger <richard@nod.at>
Signed-off-by: default avatarArtem Bityutskiy <artem.bityutskiy@linux.intel.com>
parent 55b80c40
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -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;
}