On 11/7/25 10:00 AM, Philippe Schenker wrote:
On Fri, 2025-11-07 at 09:24 -0600, Andrew Davis wrote:
On 11/7/25 7:01 AM, Philippe Schenker wrote:
From: Philippe Schenker <[email protected]>
When compiling for R5 core with CONFIG_REMOTEPROC_TI_K3_R5F,
passing 'size' (ulong) to ti_secure_image_post_process() caused
a type mismatch compiler error.
Cast 'size' to (size_t *) to fix it.
If the size of `size_t` and `ulong` are not the same this doesn't
really fix the issue, just silence the compiler warning. If ulong
is smaller than size_t on some platform we will read data outside
the variable address when de-referencing.
Might be more correct to assign size to a variable of the correct
size first, then pass a pointer to that.
Andrew
Hi Andrew, Thanks for your comment. If I understand it correctly and
explained in different words: If size_t is larger than ulong unknown
memory could be accessed.
Correct. And if size_t is smaller then on big-endian systems you
will read the wrong data.
Isn't it very unlikely that this ever
happens?
Also correct, I don't think either scenario is likely, it is
just about formal correctness. And I also didn't think any system
would have ulong and size_t be different sizes, but guess you
found a case (not sure why on R5 they are both not 32bits but
if the compiler is complaining then I guess they aren't).
At least I did interpret your first comment that way.
Anyway I will send a v3 to really catch all cases.
Thanks :)
Andrew
Signed-off-by: Philippe Schenker <[email protected]>
Acked-by: Andrew Davis <[email protected]>
---
Changes in v2:
- Added Andrew's Acked-by
drivers/remoteproc/ti_k3_r5f_rproc.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/remoteproc/ti_k3_r5f_rproc.c
b/drivers/remoteproc/ti_k3_r5f_rproc.c
index c738607c1092..e7bd97a9088b 100644
--- a/drivers/remoteproc/ti_k3_r5f_rproc.c
+++ b/drivers/remoteproc/ti_k3_r5f_rproc.c
@@ -341,7 +341,7 @@ static int k3_r5f_load(struct udevice *dev,
ulong addr, ulong size)
k3_r5f_init_tcm_memories(core, mem_auto_init);
- ti_secure_image_post_process(&image_addr, &size);
+ ti_secure_image_post_process(&image_addr, (size_t *)&size);
ret = rproc_elf_load_image(dev, addr, size);
if (ret < 0) {