[PATCH 8/9] UBI: Fix memory leak in ubi_attach_fastmap() error path
Sascha Hauer
s.hauer at pengutronix.de
Tue Jan 7 05:05:34 EST 2014
From: Richard Weinberger <richard at nod.at>
On error we have to free all three temporary lists.
Reported-by: Richard Genoud <richard.genoud at gmail.com>
Signed-off-by: Richard Weinberger <richard at nod.at>
Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
drivers/mtd/ubi/fastmap.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/drivers/mtd/ubi/fastmap.c b/drivers/mtd/ubi/fastmap.c
index 8963e06..aaa9f55 100644
--- a/drivers/mtd/ubi/fastmap.c
+++ b/drivers/mtd/ubi/fastmap.c
@@ -830,6 +830,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) {
+ free(tmp_aeb);
+ list_del(&tmp_aeb->u.list);
+ }
+ list_for_each_entry_safe(tmp_aeb, _tmp_aeb, &eba_orphans, u.list) {
+ free(tmp_aeb);
+ list_del(&tmp_aeb->u.list);
+ }
+ list_for_each_entry_safe(tmp_aeb, _tmp_aeb, &lfree, u.list) {
+ free(tmp_aeb);
+ list_del(&tmp_aeb->u.list);
+ }
+
return ret;
}
--
1.8.5.2
More information about the barebox
mailing list