On 12/31/25 11:36 AM, Beleswar Padhi wrote:
The board_fit_image_post_process() function assumes that all TIFSSTUB
images appear at the end of the image_os_match[] array by using
the condition:
i > IMAGE_ID_DM_FW
The check is (i < IMAGE_AMT && i > IMAGE_ID_DM_FW) so I has to be both
larger than IMAGE_ID_DM_FW *AND* less than IMAGE_AMT, given the enum is:
...
IMAGE_ID_DM_FW,
IMAGE_ID_TIFSSTUB_HS,
IMAGE_ID_TIFSSTUB_FS,
IMAGE_ID_TIFSSTUB_GP,
IMAGE_AMT,
...
Then only types that match this should be the 3 TIFSSTUB_* items.
That said, explicit matching is so much nicer, so you should keep this
patch but re-word the commit message.
However, this assumption breaks when new image types are appended to the
enum and the array, causing unintended image types to match this
condition and having their buffer sizes incorrectly set to 0 with:
*p_size = 0
To avoid this issue, replace the range-based check with an explicit
match for TIFSSTUB image IDs.
Signed-off-by: Beleswar Padhi <[email protected]>
---
v3: Changelog:
1. None
Link to v2:
https://lore.kernel.org/all/[email protected]/
v2: Changelog:
1. New patch. Fixes condition to allow new images to be added at the end
of the enum.
arch/arm/mach-k3/r5/common.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/arch/arm/mach-k3/r5/common.c b/arch/arm/mach-k3/r5/common.c
index 390e1324fb9..da1d1cb7230 100644
--- a/arch/arm/mach-k3/r5/common.c
+++ b/arch/arm/mach-k3/r5/common.c
@@ -366,7 +366,9 @@ void board_fit_image_post_process(const void *fit, int
node, void **p_image,
}
}
- if (i < IMAGE_AMT && i > IMAGE_ID_DM_FW) {
+ if (i < IMAGE_AMT &&
+ (i == IMAGE_ID_TIFSSTUB_HS || i == IMAGE_ID_TIFSSTUB_FS ||
+ i == IMAGE_ID_TIFSSTUB_GP)) {
You can drop the (i < IMAGE_AMT) part of the check, it will always be true
if "i" is one of the TIFSSTUB_* values, so just:
if (i == IMAGE_ID_TIFSSTUB_HS ||
i == IMAGE_ID_TIFSSTUB_FS ||
i == IMAGE_ID_TIFSSTUB_GP) {
Andrew
int device_type = get_device_type();
if ((device_type == K3_DEVICE_TYPE_HS_SE &&