]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
MIPS: Loongson64: env: Check UARTs passed by LEFI cautiously
authorRong Zhang <rongrong@oss.cipunited.com>
Sun, 15 Mar 2026 17:28:22 +0000 (01:28 +0800)
committerThomas Bogendoerfer <tsbogend@alpha.franken.de>
Wed, 1 Apr 2026 19:49:44 +0000 (21:49 +0200)
commit35d8945bf9b0c4d9586c7fa9fadeecf2cfc26c23
tree94ff45332359cc40dc0376bd9909f45066ccb06a
parent6de23f81a5e08be8fbf5e8d7e9febc72a5b5f27f
MIPS: Loongson64: env: Check UARTs passed by LEFI cautiously

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@vger.kernel.org
Reviewed-by: Yao Zi <me@ziyao.cc>
Signed-off-by: Rong Zhang <rongrong@oss.cipunited.com>
Reviewed-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
arch/mips/loongson64/env.c