[PATCH v2 2/6] remoteproc: k3-r5: cast size to size_t
Philippe Schenker
dev at pschenker.ch
Fri Nov 7 17:00:36 CET 2025
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 <philippe.schenker at impulsing.ch>
> >
> > 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. Isn't it very unlikely that this ever
happens?
At least I did interpret your first comment that way.
Anyway I will send a v3 to really catch all cases.
>
> >
> > Signed-off-by: Philippe Schenker <philippe.schenker at impulsing.ch>
> > Acked-by: Andrew Davis <afd at ti.com>
> >
> > ---
> >
> > 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) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 659 bytes
Desc: This is a digitally signed message part
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20251107/b99baa74/attachment.sig>
More information about the U-Boot
mailing list