Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3677416pxb; Mon, 24 Jan 2022 15:07:17 -0800 (PST) X-Google-Smtp-Source: ABdhPJwN5fsepb2XpdV0/KAKJHIseowxlfT/u37OD+yWLVchL2p+IuXkaphzmq85ntqIXMJ9iN8K X-Received: by 2002:a17:902:6901:b0:149:4e89:2d45 with SMTP id j1-20020a170902690100b001494e892d45mr15817784plk.22.1643065637030; Mon, 24 Jan 2022 15:07:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643065637; cv=none; d=google.com; s=arc-20160816; b=cHPM6VxKmmSImDTUprlOcZx0GpBKlGMJUqw8/yW+SmGz9qqElJXrE01ObzG4g9sMAZ li7DRs93RijuzJ2TksU6smUgOeQ+4Zpgb3zdqd3Rfr7KtVTPmKMBH4SyXCzFeI3x6J1M DQAGIFEZXS1H87d0kVfs08D3238hYkJThZLXu6F09YJkJNknQ8uv/0YG+jcqMGJYZsdw iS3Sc5VUZU4fxguEdJt1yT/YXDB3NKtjN/bjGmScv9BcguC2g48xgaHjLjw1xuQprW3d EXVMnSqsQ2lJ+tE2LO9BN96bP0zg5k9pdP6T7toj6Qjg7qzcxrWJOHsOtYpKf4CNcF/6 3Lfw== 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=BNK5W6HVYxlSWc6/ySCeIVkDPEfyZE1YDZgBiSRPxcU=; b=qLy0rilXFFYq1yoRGxBG5fIki8RQpsIGxRZByrcAXgV2fgnVM1n1uyLwHGz4+BZDgQ jG8oaOJXzsf2NLzqGgF+QswY+P30YuLhDIC1+nvt7IeRJZ7e5sMRclRzsIO8wmZAhigl se9s60Qe25hw2yUs3nyXja9scKqxo3m6FfO0sAQHZAlldFvf195Q+v/uqBVwo36Z5BqU +5zA3Cyl4YRTKUksELP5tpnupriCTPFHevEVtINW/8QVWUptwV89tScfSOCeENlCMw2f o4meroVBFz+yJsswqhZ2nahvwvvmeyUSCS0AZmXvP0Mds+COtQZS2cA5sypo8YSIcnLf D3MA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="w1TNF/TV"; 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 p10si13672903pls.262.2022.01.24.15.06.35; Mon, 24 Jan 2022 15:07:17 -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="w1TNF/TV"; 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 S1843556AbiAXXEI (ORCPT + 99 others); Mon, 24 Jan 2022 18:04:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33304 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1578722AbiAXWDV (ORCPT ); Mon, 24 Jan 2022 17:03:21 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5F72DC036BFC; Mon, 24 Jan 2022 12:41:52 -0800 (PST) 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 dfw.source.kernel.org (Postfix) with ESMTPS id F1673615D8; Mon, 24 Jan 2022 20:41:51 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D5309C340E5; Mon, 24 Jan 2022 20:41:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643056911; bh=Ht43UxNFhdmKPNTqhSR/k8BwiUdZV1+y0lRQ40YRnCE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=w1TNF/TV7M/9UdSfiYjkrqU/g7x/D1wPuSNm+V/Xxmq1HTvO2D8w7eP8uzlba5xEo mHgwHO/MoeEE2nEmvwB6MezXyyPueir1q8IWHkXWRa/Jr9f4ye6trJnRJ4/IDbZrjX iRJR2FKS/SdU0bUUvwvyWMO3DoQlrCfGalBLAbg8= 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.15 639/846] interconnect: qcom: rpm: Prevent integer overflow in rate Date: Mon, 24 Jan 2022 19:42:36 +0100 Message-Id: <20220124184123.072750615@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124184100.867127425@linuxfoundation.org> References: <20220124184100.867127425@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 54de49ca7808a..ddf1805ded0c0 100644 --- a/drivers/interconnect/qcom/icc-rpm.c +++ b/drivers/interconnect/qcom/icc-rpm.c @@ -68,6 +68,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