From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from sender4-op-o15.zoho.com (sender4-op-o15.zoho.com [136.143.188.15]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 03B9526AAAB; Sun, 15 Mar 2026 11:41:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=pass smtp.client-ip=136.143.188.15 ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773574913; cv=pass; b=cF7JXS8/rf26zSLQElqccoKU3G6elKdYKtM/Lr+vbxajLPWt0iVryJQx62SKKUeK0h2RRh24fJa6cO/ZGzMq6NXtXiZPA40aU8xootM2eZ7KoP7QOonXf1uv6SvbckbEUx5MNRd91O/IPZlmzeo/IuvRX1snBcefOS8F7aORB6o= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773574913; c=relaxed/simple; bh=YSmRuxKBO2kw+E3WKTHsuieuLjI2IbFdsM0DVKohbQE=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=YEPLusw9NjWi9QDJFjB/JzNOqGKFcrcnM27OtxTjQioOYaxstmMI6T+TR1oM4crgrPiWThTlUpiMUqGb8tKtViplDI5QxH2xxc3n6BhPF++13dhQl1YAKsKg1l710yuk2HmNOV12aDIIO0u6b7OlCiHXH1HqBF91jGwK1tbRVoo= ARC-Authentication-Results:i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ziyao.cc; spf=pass smtp.mailfrom=ziyao.cc; dkim=pass (1024-bit key) header.d=ziyao.cc header.i=me@ziyao.cc header.b=Dh0ycOU+; arc=pass smtp.client-ip=136.143.188.15 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ziyao.cc Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ziyao.cc Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ziyao.cc header.i=me@ziyao.cc header.b="Dh0ycOU+" ARC-Seal: i=1; a=rsa-sha256; t=1773574888; cv=none; d=zohomail.com; s=zohoarc; b=F8Ovw6IWDaW4TdQr4veQWCP9nnOMBUf3aabZZP0I4uPKehETDqinip9tkU4gjDtvKrNqAHp9plySAUYuB3iMg45e5lqAHcxILc8nbPY4cGKzmb7W9g8MJsGMenxJ3m7lobgxkzdFpO3APXPCaJ+3wPNeQ5xrahkVbQEEXHFmhgQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1773574888; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:Subject:To:To:Message-Id:Reply-To; bh=uN8w1OeE6HEvMiWwhvg2LiJ/nLSS/nbJhI/YzLpKiTA=; b=H6zdgdlFhUMsaNNbu6UXpSS8BnZGLrs47dPaSGMptIC6U8nvaMS8regzhpPRMcuW7OixZlQZ7pnQLNi49mIf4NyYYVPatJTh/faxw0VmQJ+hWRkRNyL4n93b2/fsIejVvUdIKMd+JV2FLaYGzNFCpz89EQ3CR5S6tv2M4SCYrGs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=ziyao.cc; spf=pass smtp.mailfrom=me@ziyao.cc; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1773574888; s=zmail; d=ziyao.cc; i=me@ziyao.cc; h=Date:Date:From:From:To:To:Cc:Cc:Subject:Subject:Message-ID:References:MIME-Version:Content-Type:In-Reply-To:Message-Id:Reply-To; bh=uN8w1OeE6HEvMiWwhvg2LiJ/nLSS/nbJhI/YzLpKiTA=; b=Dh0ycOU+kMmTiXKP7rMt5W1VyD/yZcNTmLN0qbGxwFjIJw/sH6Bg7Gfnpc+8ctpq BMU568G6xLDKMC0gA1ael0PGbfaaklyK1JaLbzvo0RGxkWZYWn4zWIv7/W3uFudBefM 2CJpJBMGF1lJYc35IH0t/2GD58h546huyJIdvJ3c= Received: by mx.zohomail.com with SMTPS id 1773574884580662.9489585086674; Sun, 15 Mar 2026 04:41:24 -0700 (PDT) Date: Sun, 15 Mar 2026 11:41:16 +0000 From: Yao Zi To: "Rong Zhang" , "Huacai Chen" , "Jiaxun Yang" , "Thomas Bogendoerfer" Cc: , , "Icenowy Zheng" , "Rong Zhang" , Subject: Re: [PATCH] MIPS: Loongson64: env: Check UARTs passed by LEFI cautiously Message-ID: References: <20260314211336.408561-1-rongrong@oss.cipunited.com> Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20260314211336.408561-1-rongrong@oss.cipunited.com> X-ZohoMailClient: External X-ZohoMail-Owner: +zmo_0_me@ziyao.cc On Sun, Mar 15, 2026 at 05:13:29AM +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@vger.kernel.org > Signed-off-by: Rong Zhang > --- > arch/mips/loongson64/env.c | 18 +++++++++++++++++- > 1 file changed, 17 insertions(+), 1 deletion(-) > > diff --git a/arch/mips/loongson64/env.c b/arch/mips/loongson64/env.c > index 11ddf02d6a15..c6b99b3740ea 100644 > --- a/arch/mips/loongson64/env.c > +++ b/arch/mips/loongson64/env.c > @@ -17,8 +17,10 @@ > #include > #include > #include > +#include > #include > #include > +#include Maybe putting this before string_choices.h to keep the headers sorted at least locally? Though the order is already broken, this may minimize the diff if someone is willing to sort them later. > #include > #include > #include Reviewed-by: Yao Zi Thanks, Yao Zi