Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3648728pxb; Mon, 24 Jan 2022 14:23:33 -0800 (PST) X-Google-Smtp-Source: ABdhPJxITydjUh7akLZAVTUTdPxs22UZBemFKOFMZyFjdkPdV6WH/nhCYog3QIbd8Dy/kQ7G9ebp X-Received: by 2002:a63:69c4:: with SMTP id e187mr13465921pgc.442.1643063013417; Mon, 24 Jan 2022 14:23:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643063013; cv=none; d=google.com; s=arc-20160816; b=r9bekQSkPZwIhFNyBY9kUavvS2a6WVgxffcVzJSkNer4N4KbuJeAkJDw+M/wLvrdv3 5PrtLw4rUrsi4wCAZ5WNiWr8HehcLX0at5K4PPDyHdCzX3e51ASfLiWA26yDiPF4DuyG 6Frq94d1wb8vIVrX2vHKf53rPY0QVImpIUKFeFtwT8BkYuMVg2PATjV419Gx668MJ6Q3 284DPCRjTqgcLRRIpasjuCqeXwIRkVTe8mDZySGNdwO9MvFmpbv3JrZoc3pzIB/nDjaQ m/1qavr2dMSr84fFvm3ZPRJCvMt+4s3QjUf3/GNMQAXFxluvuDUfKU3nGDvuE379V2K4 QL+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=c9Xt6J0wRQuM4s0OiAeHOOSiuRBKc7tLnyreR3KD3DI=; b=QWVaUve0eHtOlaOXtt6fUYAGb2zjz47p125QSl2yh+MeHGyp0THDjFEFiEK8iOwkZ6 pHsqoWjcBhk3Xab8tXkHj0YfaR+7HdZ1CZ2DtcFKS7exbXTY0ki/6kvhAbc0KNWCESCP x8f0Dbl/UWhI/D3/X3pfKchK0ZBHpaWbl4SvpI+7El8lFaOzdZQZmLZa+BxL7Afa5DL+ ARUtybDQa2SlutYQuw5cRkzdH4rBORv3+j/G6hX+hIlblvySINzA/1fh99ah+yXZi9Pb cBapS+jjI28DxUq7GFIBF3QhRZRk1XBn0SHeI9KNAgny2ZiSvmHkWCZz7e21+OskyAoK 1YmQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=jRPM2FuH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 67si15448243pgi.250.2022.01.24.14.23.21; Mon, 24 Jan 2022 14:23:33 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=jRPM2FuH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1582100AbiAXWNx (ORCPT + 99 others); Mon, 24 Jan 2022 17:13:53 -0500 Received: from ams.source.kernel.org ([145.40.68.75]:45328 "EHLO ams.source.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1453726AbiAXVar (ORCPT ); Mon, 24 Jan 2022 16:30:47 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 111F0B8121C; Mon, 24 Jan 2022 21:30:44 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 32098C340E5; Mon, 24 Jan 2022 21:30:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643059842; bh=4RrGe9wr71LWzqgF6XSoStKYKDl1f6S25cA8dDWoh9o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jRPM2FuHY04uZC7yGPukn7yAC5fiDjhNda7nD9KfDfDI2J7zB2J0vn1izh6OaI0ty wwKdhPG8uND/Yx+Rwvk6AgGdm/zxWkbxBEThQZ6Cib53iCRbSO4AtDXr5BiAlz1izb 26zGy3ln77P0/AT6ROxULvbt0n2eoCtAiOYTkuew= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Stephan Gerhold , Georgi Djakov , Sasha Levin Subject: [PATCH 5.16 0752/1039] interconnect: qcom: rpm: Prevent integer overflow in rate Date: Mon, 24 Jan 2022 19:42:21 +0100 Message-Id: <20220124184150.612174636@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124184125.121143506@linuxfoundation.org> References: <20220124184125.121143506@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Stephan Gerhold [ Upstream commit a7d9436a6c85fcb8843c910fd323dcd7f839bf63 ] Using icc-rpm on ARM32 currently results in clk_set_rate() errors during boot, e.g. "bus clk_set_rate error: -22". This is very similar to commit 7381e27b1e56 ("interconnect: qcom: msm8974: Prevent integer overflow in rate") where the u64 is converted to a signed long during clock rate rounding, resulting in an overflow on 32-bit platforms. Let's fix it similarly by making sure that the rate does not exceed LONG_MAX. Such high clock rates will surely result in the maximum frequency of the bus anyway. Signed-off-by: Stephan Gerhold Link: https://lore.kernel.org/r/20211206114542.45325-1-stephan@gerhold.net Signed-off-by: Georgi Djakov Signed-off-by: Sasha Levin --- drivers/interconnect/qcom/icc-rpm.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/interconnect/qcom/icc-rpm.c b/drivers/interconnect/qcom/icc-rpm.c index ef7999a08c8bf..8114295a83129 100644 --- a/drivers/interconnect/qcom/icc-rpm.c +++ b/drivers/interconnect/qcom/icc-rpm.c @@ -239,6 +239,7 @@ static int qcom_icc_set(struct icc_node *src, struct icc_node *dst) rate = max(sum_bw, max_peak_bw); do_div(rate, qn->buswidth); + rate = min_t(u64, rate, LONG_MAX); if (qn->rate == rate) return 0; -- 2.34.1