[PATCH 1/2] discover/syslinux-parser: clean up boot option list entries

Brett Grandbois brett.grandbois at opengear.com
Thu Apr 12 16:12:53 AEST 2018


in finalize loop or we can get duplicate boot entries as well as
the memory leak

Signed-off-by: Brett Grandbois <brett.grandbois at opengear.com>
---
 discover/syslinux-parser.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/discover/syslinux-parser.c b/discover/syslinux-parser.c
index d948765..8f5bfeb 100644
--- a/discover/syslinux-parser.c
+++ b/discover/syslinux-parser.c
@@ -310,20 +310,21 @@ static void syslinux_finalize(struct conf_context *conf)
 		implicit_image = false;
 
 	list_for_each_entry(&state->processed_options, syslinux_opt, list) {
+		list_remove(&syslinux_opt->list);
 		/* need a valid image */
 		if (!syslinux_opt->image)
-			continue;
+			goto next;
 
 		image = syslinux_opt->image;
 		label = syslinux_opt->label;
 
 		/* if implicit is disabled we must have a label */
 		if (!label && !implicit_image)
-			continue;
+			goto next;
 
 		d_opt = discover_boot_option_create(dc, dc->device);
 		if (!d_opt)
-			continue;
+			goto next;
 		if (!d_opt->option)
 			goto fail;
 
@@ -403,8 +404,11 @@ static void syslinux_finalize(struct conf_context *conf)
 		conf_strip_str(opt->description);
 
 		discover_context_add_boot_option(dc, d_opt);
+next:
+		talloc_free(syslinux_opt);
 		continue;
 fail:
+		talloc_free(syslinux_opt);
 		talloc_free(d_opt);
 	}
 }
-- 
2.7.4



More information about the Petitboot mailing list