summaryrefslogtreecommitdiffstats
path: root/discover
diff options
context:
space:
mode:
authorJeremy Kerr <jk@ozlabs.org>2013-11-27 19:47:37 +0800
committerJeremy Kerr <jk@ozlabs.org>2013-11-27 19:49:33 +0800
commitcfcffbc8ff1a9e699ca1e8073b7bc3d10c399563 (patch)
treed32e9c2ed31bd7f2176ba52df45f150c974c1aea /discover
parent25e353275fb55192fbd80c3bbe012df17e35a09f (diff)
downloadtalos-petitboot-cfcffbc8ff1a9e699ca1e8073b7bc3d10c399563.tar.gz
talos-petitboot-cfcffbc8ff1a9e699ca1e8073b7bc3d10c399563.zip
discover/grub2: Use parser for a single parse
Currently, we re-use a grub2 parser for different filenames, and will create one even if we find no matching files. This change only creates a parser if parser_request_file succeeds, and free() (and exits the parse) immediately after. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Diffstat (limited to 'discover')
-rw-r--r--discover/grub2/grub2.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/discover/grub2/grub2.c b/discover/grub2/grub2.c
index e942f68..ffb6ece 100644
--- a/discover/grub2/grub2.c
+++ b/discover/grub2/grub2.c
@@ -97,18 +97,18 @@ static int grub2_parse(struct discover_context *dc)
if (dc->event)
return -1;
- parser = grub2_parser_create(dc);
-
for (filename = grub2_conf_files; *filename; filename++) {
rc = parser_request_file(dc, dc->device, *filename, &buf, &len);
if (rc)
continue;
+ parser = grub2_parser_create(dc);
grub2_parser_parse(parser, buf, len);
talloc_free(buf);
+ talloc_free(parser);
+ break;
}
- talloc_free(parser);
return 0;
}
OpenPOWER on IntegriCloud