We free nfspath, while there is still a dangling reference to it in
the `name' variable:
nfspath = parse_nfs_url(name);
if (nfspath)
name = nfspath;
...
free(nfspath);
if (IS_ENABLED(CONFIG_COMMAND_SUPPORT) && !found) {
const char *path;
if (*name != '/')
Fix this by freeing it at the end of function.
Fixes: b5c00912524d ("boot: move nfs:// parsing out of bootloader spec code")
Reported-by: Chali Anis <[email protected]>
Assisted-by: Claude:opus-5
Signed-off-by: Ahmad Fatoum <[email protected]>
---
common/boot.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/common/boot.c b/common/boot.c
index dc1441d0dc91..0dbe8784d40c 100644
--- a/common/boot.c
+++ b/common/boot.c
@@ -473,8 +473,6 @@ int bootentry_create_from_name(struct bootentries
*bootentries,
bootentries_merge(bootentries, &provider_bootentries);
}
- free(nfspath);
-
if (IS_ENABLED(CONFIG_COMMAND_SUPPORT) && !found) {
const char *path;
@@ -490,6 +488,8 @@ int bootentry_create_from_name(struct bootentries
*bootentries,
free_const(path);
}
+ free(nfspath);
+
return found;
}
--
2.47.3