mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] boot: don't use the nfs:// mount path after freeing it
@ 2026-08-26 10:13 Ahmad Fatoum
  2026-08-28 12:16 ` Sascha Hauer
  0 siblings, 1 reply; 2+ messages in thread
From: Ahmad Fatoum @ 2026-08-26 10:13 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum, Chali Anis

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 <chalianis1@gmail.com>
Assisted-by: Claude:opus-5
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 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




^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] boot: don't use the nfs:// mount path after freeing it
  2026-08-26 10:13 [PATCH] boot: don't use the nfs:// mount path after freeing it Ahmad Fatoum
@ 2026-08-28 12:16 ` Sascha Hauer
  0 siblings, 0 replies; 2+ messages in thread
From: Sascha Hauer @ 2026-08-28 12:16 UTC (permalink / raw)
  To: barebox, Ahmad Fatoum; +Cc: Chali Anis


On Wed, 26 Aug 2026 12:13:33 +0200, Ahmad Fatoum wrote:
> 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);
> 
> [...]

Applied, thanks!

[1/1] boot: don't use the nfs:// mount path after freeing it
      https://git.pengutronix.de/cgit/barebox/commit/?id=ae383ffe08ff (link may not be stable)

Best regards,
-- 
Sascha Hauer <s.hauer@pengutronix.de>




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-08-28 12:17 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-08-26 10:13 [PATCH] boot: don't use the nfs:// mount path after freeing it Ahmad Fatoum
2026-08-28 12:16 ` Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox