mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH master 1/3] fs: add only successful filesystem probes to fs_device_list
@ 2025-04-04 15:55 Ahmad Fatoum
  2025-04-04 15:55 ` [PATCH master 2/3] common: pe: fix crash when pe_load was not called Ahmad Fatoum
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Ahmad Fatoum @ 2025-04-04 15:55 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

fs_init_legacy can't fail currently, but if it does in future, we can
end up with a file system added to fs_device_list that wasn't
successfully probed.

Move the list_add_tail to the end to avoid this.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 fs/fs.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/fs.c b/fs/fs.c
index 48a6e960e812..4d201d1b0db8 100644
--- a/fs/fs.c
+++ b/fs/fs.c
@@ -782,14 +782,14 @@ static int fs_probe(struct device *dev)
 
 	fsdev->driver = fsdrv;
 
-	list_add_tail(&fsdev->list, &fs_device_list);
-
 	if (IS_ENABLED(CONFIG_FS_LEGACY) && !fsdev->sb.s_root) {
 		ret = fs_init_legacy(fsdev);
 		if (ret)
 			return ret;
 	}
 
+	list_add_tail(&fsdev->list, &fs_device_list);
+
 	return 0;
 }
 
-- 
2.39.5




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

* [PATCH master 2/3] common: pe: fix crash when pe_load was not called
  2025-04-04 15:55 [PATCH master 1/3] fs: add only successful filesystem probes to fs_device_list Ahmad Fatoum
@ 2025-04-04 15:55 ` Ahmad Fatoum
  2025-04-04 15:55 ` [PATCH master 3/3] barebox.h: annotate __hang as __noreturn Ahmad Fatoum
  2025-04-07  7:32 ` [PATCH master 1/3] fs: add only successful filesystem probes to fs_device_list Sascha Hauer
  2 siblings, 0 replies; 4+ messages in thread
From: Ahmad Fatoum @ 2025-04-04 15:55 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

pe_close is the counterpart to pe_open. pe->code is set to non-NULL
outside pe_open by pe_load, so we should check for NULL before
attempting to free the SDRAM region.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 common/pe.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/common/pe.c b/common/pe.c
index 65d456a2c332..fd99761bddfd 100644
--- a/common/pe.c
+++ b/common/pe.c
@@ -373,7 +373,8 @@ int pe_load(struct pe_image *pe)
 
 void pe_close(struct pe_image *pe)
 {
-	release_sdram_region(pe->code);
+	if (pe->code)
+		release_sdram_region(pe->code);
 	free(pe->bin);
 	free(pe);
 }
-- 
2.39.5




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

* [PATCH master 3/3] barebox.h: annotate __hang as __noreturn
  2025-04-04 15:55 [PATCH master 1/3] fs: add only successful filesystem probes to fs_device_list Ahmad Fatoum
  2025-04-04 15:55 ` [PATCH master 2/3] common: pe: fix crash when pe_load was not called Ahmad Fatoum
@ 2025-04-04 15:55 ` Ahmad Fatoum
  2025-04-07  7:32 ` [PATCH master 1/3] fs: add only successful filesystem probes to fs_device_list Sascha Hauer
  2 siblings, 0 replies; 4+ messages in thread
From: Ahmad Fatoum @ 2025-04-04 15:55 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

Otherwise, GCC may complain that other __noreturn functions calling
__hang can in fact return.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 include/barebox.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/barebox.h b/include/barebox.h
index 334dcfceffcf..02228451c26e 100644
--- a/include/barebox.h
+++ b/include/barebox.h
@@ -6,7 +6,7 @@
 #include <linux/compiler.h>
 
 /* For use when unrelocated */
-static inline void __hang(void)
+static inline __noreturn void __hang(void)
 {
 	while (1);
 }
-- 
2.39.5




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

* Re: [PATCH master 1/3] fs: add only successful filesystem probes to fs_device_list
  2025-04-04 15:55 [PATCH master 1/3] fs: add only successful filesystem probes to fs_device_list Ahmad Fatoum
  2025-04-04 15:55 ` [PATCH master 2/3] common: pe: fix crash when pe_load was not called Ahmad Fatoum
  2025-04-04 15:55 ` [PATCH master 3/3] barebox.h: annotate __hang as __noreturn Ahmad Fatoum
@ 2025-04-07  7:32 ` Sascha Hauer
  2 siblings, 0 replies; 4+ messages in thread
From: Sascha Hauer @ 2025-04-07  7:32 UTC (permalink / raw)
  To: barebox, Ahmad Fatoum


On Fri, 04 Apr 2025 17:55:19 +0200, Ahmad Fatoum wrote:
> fs_init_legacy can't fail currently, but if it does in future, we can
> end up with a file system added to fs_device_list that wasn't
> successfully probed.
> 
> Move the list_add_tail to the end to avoid this.
> 
> 
> [...]

Applied, thanks!

[1/3] fs: add only successful filesystem probes to fs_device_list
      https://git.pengutronix.de/cgit/barebox/commit/?id=356a8b6b240f (link may not be stable)
[2/3] common: pe: fix crash when pe_load was not called
      https://git.pengutronix.de/cgit/barebox/commit/?id=8a63d86b063a (link may not be stable)
[3/3] barebox.h: annotate __hang as __noreturn
      https://git.pengutronix.de/cgit/barebox/commit/?id=ac20c565e06b (link may not be stable)

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




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

end of thread, other threads:[~2025-04-07  7:56 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-04-04 15:55 [PATCH master 1/3] fs: add only successful filesystem probes to fs_device_list Ahmad Fatoum
2025-04-04 15:55 ` [PATCH master 2/3] common: pe: fix crash when pe_load was not called Ahmad Fatoum
2025-04-04 15:55 ` [PATCH master 3/3] barebox.h: annotate __hang as __noreturn Ahmad Fatoum
2025-04-07  7:32 ` [PATCH master 1/3] fs: add only successful filesystem probes to fs_device_list Sascha Hauer

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