Skip to contentSkip to conversation

common/spl: fix endless loop in spl_fit_append_fdt()

PATCH Superseded Michael Walle 2 participants 3 messages Oct 27, 2025 – Oct 31, 2025

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 common/spl: fix endless loop in spl_fit_append_fdt()

Technically, commit 24bf44cf88e7 ("spl: fit: Do not fail immediately if an overlay is not available") introduced that regression as the code will never advance if spl_fit_get_image_name() will return an error. But at that time, spl_fit_get_image_node() was used in spl_fit_append_fdt() which calls fdt_subnode_offset() to get the image node. And I presume the commit was about the latter failing gracefully and trying the next one.

But with commit b13eaf3bb4e6 ("spl: fit: Add board level function to decide application of DTO") that behavior changed and the loop in spl_fit_append_fdt() no longer uses spl_fit_get_image_node() but spl_fit_get_image_name() directly. Thus it doesn't make any sense to not break the loop if that fails.

Also, the original use case of commit 24bf44cf88e7 ("spl: fit: Do not fail immediately if an overlay is not available") is preserved because spl_subnode_offset() is now called within the loop and errors are handled gracefully (and advancing the index).

Fixes b13eaf3bb4e6 ("spl: fit: Add board level function to decide application of DTO")
---
 common/spl/spl_fit.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
common/spl/spl_fit.c +2 -2
index 746c3d2fa28..342262dd112 100644
@@ -448,8 +448,8 @@ static int spl_fit_append_fdt(struct spl_image_info *spl_image,
 				debug("%s: No additional FDT node\n", __func__);
 				ret = 0;
 				break;
-			} else if (ret < 0) {
-				continue;
+			} else {
+				break;
 			}
 
 			ret = board_spl_fit_append_fdt_skip(str);
Signature · 1 line
2.47.3
Reviewed-by on v1 1/1
#1 lore raw
Quoted 14 lines · Michael Walle

Technically, commit 24bf44cf88e7 ("spl: fit: Do not fail immediately if an overlay is not available") introduced that regression as the code will never advance if spl_fit_get_image_name() will return an error. But at that time, spl_fit_get_image_node() was used in spl_fit_append_fdt() which calls fdt_subnode_offset() to get the image node. And I presume the commit was about the latter failing gracefully and trying the next one.

But with commit b13eaf3bb4e6 ("spl: fit: Add board level function to decide application of DTO") that behavior changed and the loop in spl_fit_append_fdt() no longer uses spl_fit_get_image_node() but spl_fit_get_image_name() directly. Thus it doesn't make any sense to not break the loop if that fails.

Quoted 7 lines

Also, the original use case of commit 24bf44cf88e7 ("spl: fit: Do not fail immediately if an overlay is not available") is preserved because spl_subnode_offset() is now called within the loop and errors are handled gracefully (and advancing the index).

Fixes b13eaf3bb4e6 ("spl: fit: Add board level function to decide application of DTO")

Thanks for explaining what's going on in such detail.

Signature · 1 line
Tom
#2 lore raw
Quoted 21 lines · Tom Rini
Quoted 19 lines · Michael Walle

Technically, commit 24bf44cf88e7 ("spl: fit: Do not fail immediately if an overlay is not available") introduced that regression as the code will never advance if spl_fit_get_image_name() will return an error. But at that time, spl_fit_get_image_node() was used in spl_fit_append_fdt() which calls fdt_subnode_offset() to get the image node. And I presume the commit was about the latter failing gracefully and trying the next one.

But with commit b13eaf3bb4e6 ("spl: fit: Add board level function to decide application of DTO") that behavior changed and the loop in spl_fit_append_fdt() no longer uses spl_fit_get_image_node() but spl_fit_get_image_name() directly. Thus it doesn't make any sense to not break the loop if that fails.

Also, the original use case of commit 24bf44cf88e7 ("spl: fit: Do not fail immediately if an overlay is not available") is preserved because spl_subnode_offset() is now called within the loop and errors are handled gracefully (and advancing the index).

Quoted 6 lines
Quoted 2 lines
Fixes b13eaf3bb4e6 ("spl: fit: Add board level function to decide application of DTO")

Thanks for explaining what's going on in such detail.

Please don't pick this up. There will be a v2 as this is breaking any subsequent code in the loop.

-michael