From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 AECF0254B03; Wed, 25 Feb 2026 01:37:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771983443; cv=none; b=JsnRFToqR7NW7I92OYvPa6iz1y20Bj8NvczN1GbbuXSZaxrfTFCfX8QDSDiNHMezXpWtUBSovWC8o9K1rVIWBjn/6urrBMW3nas6GmYLnzyf2uJRm7aYhQNtmVa3TyPnXfBxChuzQ25AYKJttGJ2veG3KvfhMlP+E1r4Mv6FwA4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771983443; c=relaxed/simple; bh=pfJqqnE5YIU0HdUoyL5fazcvZHFg3nQlhTD0lcM9WwY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=KP7o8OekHgY8bJbN9w5SvKhjYL3w0fYL3JNagKMIlZCAj8hjnJHbzgB9STmItn6tWy2AJK7Nu22bwOcf54AOkH3++pVQEBi5hXGGYtzSrbw2x/1T9sRDiM88LVYrPQSPpnWcfm88wGs6TdIb2RBYcMnlHXVhVqQ9KbyblyR3yBI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=aL/1dO08; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="aL/1dO08" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6150AC116D0; Wed, 25 Feb 2026 01:37:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1771983443; bh=pfJqqnE5YIU0HdUoyL5fazcvZHFg3nQlhTD0lcM9WwY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aL/1dO08FNbUaxzZ91bxIEWKAu5J+2A3UzwGO5c0NlRUlhvLP93pC44pfVWmL+WN+ r2AaH2YmhJ16ljaYp1p5OuIitFH0LblasEtf1sW+Am2460Mi1cqcoWvAlF91s7G1g1 CBPavxhYgFC9STHX8MoARKT7A92mcbVJtFIYJzIY= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, AngeloGioacchino Del Regno , Nicolas Frattaroli , Georgi Djakov , Sasha Levin Subject: [PATCH 6.19 560/781] interconnect: mediatek: Aggregate bandwidth with saturating add Date: Tue, 24 Feb 2026 17:21:09 -0800 Message-ID: <20260225012413.536807658@linuxfoundation.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260225012359.695468795@linuxfoundation.org> References: <20260225012359.695468795@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.19-stable review patch. If anyone has any objections, please let me know. ------------------ From: Nicolas Frattaroli [ Upstream commit 6ffd02b82243d9907b5f5d2c7a2fc6a62669eece ] By using a regular non-overflow-checking add, the MediaTek icc-emi driver will happy wrap at U32_MAX + 1 to 0. As it's common for the interconnect core to fill in INT_MAX values, this is not a hypothetical situation, but something that actually happens in regular use. This would be pretty disasterous if anything used this driver. Replace the addition with an overflow-checked addition from overflow.h, and saturate to U32_MAX if an overflow is detected. Fixes: b45293799f75 ("interconnect: mediatek: Add MediaTek MT8183/8195 EMI Interconnect driver") Reviewed-by: AngeloGioacchino Del Regno Signed-off-by: Nicolas Frattaroli Link: https://lore.kernel.org/r/20251124-mt8196-dvfsrc-v2-13-d9c1334db9f3@collabora.com Signed-off-by: Georgi Djakov Signed-off-by: Sasha Levin --- drivers/interconnect/mediatek/icc-emi.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/interconnect/mediatek/icc-emi.c b/drivers/interconnect/mediatek/icc-emi.c index 182aa2b0623af..dfa3a9cd93998 100644 --- a/drivers/interconnect/mediatek/icc-emi.c +++ b/drivers/interconnect/mediatek/icc-emi.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include @@ -22,7 +23,9 @@ static int mtk_emi_icc_aggregate(struct icc_node *node, u32 tag, u32 avg_bw, { struct mtk_icc_node *in = node->data; - *agg_avg += avg_bw; + if (check_add_overflow(*agg_avg, avg_bw, agg_avg)) + *agg_avg = U32_MAX; + *agg_peak = max_t(u32, *agg_peak, peak_bw); in->sum_avg = *agg_avg; -- 2.51.0