Re: [PATCH v2] MIPS: Loongson64: env: Check UARTs passed by LEFI cautiously

From: Thomas Bogendoerfer

Date: Wed Apr 01 2026 - 16:36:06 EST


On Mon, Mar 16, 2026 at 01:28:22AM +0800, Rong Zhang wrote:
> Some firmware does not set nr_uarts properly and passes empty items.
> Iterate at most min(system->nr_uarts, MAX_UARTS) items to prevent
> out-of-bounds access, and ignore UARTs with addr 0 silently.
>
> Meanwhile, our DT only works with UPIO_MEM but theoretically firmware
> may pass other IO types, so explicitly check against that.
>
> Tested on Loongson-LS3A4000-7A1000-NUC-SE.
>
> Fixes: 3989ed418483 ("MIPS: Loongson64: env: Fixup serial clock-frequency when using LEFI")
> Cc: stable@xxxxxxxxxxxxxxx
> Reviewed-by: Yao Zi <me@xxxxxxxx>
> Signed-off-by: Rong Zhang <rongrong@xxxxxxxxxxxxxxxxx>
> ---
> Changes in v2:
> - Sort new includes alphabetically (thanks Yao Zi)
> ---
> arch/mips/loongson64/env.c | 18 +++++++++++++++++-
> 1 file changed, 17 insertions(+), 1 deletion(-)

applied to mips-fixes

Thomas.

--
Crap can work. Given enough thrust pigs will fly, but it's not necessarily a
good idea. [ RFC1925, 2.3 ]