Re: [PATCH 3/4] bus: ti-sysc: Fix module register ioremap for larger offsets

From: Tony Lindgren
Date: Wed Aug 22 2018 - 12:44:20 EST


* Tony Lindgren <tony@xxxxxxxxxxx> [180808 08:11]:
> static int sysc_ioremap(struct sysc *ddata)
> {
> - u32 size = 0;
> -
> - if (ddata->offsets[SYSC_SYSSTATUS] >= 0)
> - size = ddata->offsets[SYSC_SYSSTATUS];
> - else if (ddata->offsets[SYSC_SYSCONFIG] >= 0)
> - size = ddata->offsets[SYSC_SYSCONFIG];
> - else if (ddata->offsets[SYSC_REVISION] >= 0)
> - size = ddata->offsets[SYSC_REVISION];
> - else
> + u32 size;
> +
> + size = max3(ddata->offsets[SYSC_REVISION],
> + ddata->offsets[SYSC_SYSCONFIG],
> + ddata->offsets[SYSC_SYSSTATUS]);

Above should use int size, not u32 size as we can have
-ENODEV for non-existing registers. And we should also
check the registeroffset is not beyond the module range
as pointed out by Dan Carpenter.

Updated patch below with these issues fixed.

Regards,

Tony

8< -----------