Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp1321609pxb; Fri, 6 Nov 2020 06:51:35 -0800 (PST) X-Google-Smtp-Source: ABdhPJyvRm4Sfc460HZmXHqfZIwKEK74YoW6aIZMNAHMCGNkWg/zTm4DuHaa54IA1yZZE2CaBlLP X-Received: by 2002:aa7:d858:: with SMTP id f24mr2336485eds.12.1604674295661; Fri, 06 Nov 2020 06:51:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604674295; cv=none; d=google.com; s=arc-20160816; b=I2ZPROVgjAvtcii/DM+UxWmU3wYg9HpduGU/815e60QMO1ZcRp6/7TKoqM27zz8Y1x hJEjNR8C5kdjWrLXmiDZc/g4DVbnjcksFamGI0VaCEZ7V7E0iXIoYx99joNEzGXY0SGq vqOD+k0LLq1BliEPk0E2QyEa9ga2IteLHH/Rbmyp5EBl9beMshXjKXKIpBn1aDHyG5E6 jim+EWyGblz4fLxm+iQl0rFRSZqIb11AuD3rc5uZ1/ptuLItL0DMfGJIxaLCG3uG0q7I /qeqHDL5Pooby72K+fjC06Kx84lPC28tCuOqLgmI0Gw3ZQletpDNefUnZw55Fggg3mFi a/cg== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=IKUVdCXUzjzLxhYYwZ9oyOQfl5zsmsvI+sfdYUlShXc=; b=sTh884EWzoLHpzXN7jeUQvAzQbWcFGhzEyD2cVUrQmUhHcbADrNVUD4IvUAkKnt8Dy 6PcqnrIWDbG8c7E7mG9jDQ5VwKV0V/aGInNqiGdZt+BUHhk9xLtNlXIzOF9KHELifPEe N2Od3kAbeHwE7b9HZkkhTTCoTi8LlJHUbu7Ddr3vFvng32RFyg/A/LYLXX0s8UhvracE QrAVVQJ6jPBhjee8VZjYBSJdcIO2I/E23tU76mwXBSy6SM/RueueyD3FBAwzaRKQW8tq X2MA+Gu2re0lhAyHJUoq0RqRflTCGSK24/F3CiutM2OBAbor+gj18OxKGFhzaAuMI5Z5 Sjgw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Lv+WXdyd; 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=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h90si1053076edd.326.2020.11.06.06.51.12; Fri, 06 Nov 2020 06:51:35 -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=@linaro.org header.s=google header.b=Lv+WXdyd; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727497AbgKFOsr (ORCPT + 99 others); Fri, 6 Nov 2020 09:48:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46958 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727487AbgKFOsq (ORCPT ); Fri, 6 Nov 2020 09:48:46 -0500 Received: from mail-wr1-x443.google.com (mail-wr1-x443.google.com [IPv6:2a00:1450:4864:20::443]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2AC4AC0613D3 for ; Fri, 6 Nov 2020 06:48:46 -0800 (PST) Received: by mail-wr1-x443.google.com with SMTP id y12so1598686wrp.6 for ; Fri, 06 Nov 2020 06:48:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=IKUVdCXUzjzLxhYYwZ9oyOQfl5zsmsvI+sfdYUlShXc=; b=Lv+WXdyd4ryinhARuEv8v1Ng3HyuRyBWyQmuuR3lozyQ5XKqcmeJuXFDhpAxNArAPw UqTuNiMKkMNAFshYcuw99anJkxXLhcLqWkJvmyPROYdj5bMzxG9dxnhRmygG8QaXDZvp vV7j6n3oXwtLOS42Xhy6Odx1ggkz+uiH8y66zylZFdoXAskBfbsrhRktT1wTdj2lzfMx wLN6rt++C0nvgoJrKxuaYh4XgbTDb6TbIhgSYj5VelHNJGFTwO+EBpkmXqy3dw4KZu+3 4j9PUT1ybDiaOtmD4yeHvVeFHI4EJ4eY+YiTHiUm+V0xGc0kwzBkHF7FyD9ETaqtCV/a I7kA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=IKUVdCXUzjzLxhYYwZ9oyOQfl5zsmsvI+sfdYUlShXc=; b=gYEmbIrL+8aAvmFASFsI6CDrw2zbxSQA0Okia5OZxFcCcZmfXtmlw5xlNZGjOiEq11 yeC0ClWxKxg/7wfzXV9TNNCqFGMFh9+9kyAqpYvs/u1AtqmASZjS4Lv3z+ItDLcERED4 gkUrAln8+bzd1v7visqsKtjwpTbwChI6cZE2/YOhL4ghC/RBW74G/86zibDrz9igyCnR o+4LqtFehdG3Tf8+OO2N2mKdk/DMytOYOPgtwTisG8BjZEO3OjjhQAcB33lZa73s18sz PV8fjTeUnJ+4d6H/Dm2y7yRVmrsss4r0DpiWJRjJR8AtEKjauY+DCNtgeIR+SK2KvQII fQ1A== X-Gm-Message-State: AOAM530siMwHmPlhsbE++Ax7KOlEDCbKEKE3Vn2WTaU4ctwkZDPcxFwS lPsOQVgsDr4HCpxU55Y/bYQt9Q== X-Received: by 2002:a5d:56c7:: with SMTP id m7mr3294056wrw.201.1604674124796; Fri, 06 Nov 2020 06:48:44 -0800 (PST) Received: from localhost.localdomain ([212.45.67.2]) by smtp.googlemail.com with ESMTPSA id z2sm2657136wmf.45.2020.11.06.06.48.43 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 06 Nov 2020 06:48:44 -0800 (PST) From: Georgi Djakov To: linux-pm@vger.kernel.org, luca@z3ntu.xyz, masneyb@onstation.org Cc: bjorn.andersson@linaro.org, saravanak@google.com, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, Georgi Djakov Subject: [PATCH] interconnect: qcom: msm8974: Prevent integer overflow in rate Date: Fri, 6 Nov 2020 16:48:47 +0200 Message-Id: <20201106144847.7726-1-georgi.djakov@linaro.org> X-Mailer: git-send-email 2.28.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When sync_state support got introduced recently, by default we try to set the NoCs to run initially at maximum rate. But as these values are aggregated, we may end with a really big clock rate value, which is then converted from "u64" to "long" during the clock rate rounding. But on 32bit platforms this may result an overflow. Fix it by making sure that the rate is within range. Reported-by: Luca Weiss Fixes: b1d681d8d324 ("interconnect: Add sync state support") Signed-off-by: Georgi Djakov --- drivers/interconnect/qcom/msm8974.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/interconnect/qcom/msm8974.c b/drivers/interconnect/qcom/msm8974.c index 3a313e11e73d..b6b639dad691 100644 --- a/drivers/interconnect/qcom/msm8974.c +++ b/drivers/interconnect/qcom/msm8974.c @@ -618,6 +618,8 @@ static int msm8974_icc_set(struct icc_node *src, struct icc_node *dst) do_div(rate, src_qn->buswidth); + rate = min_t(u32, rate, INT_MAX); + if (src_qn->rate == rate) return 0; @@ -758,6 +760,7 @@ static struct platform_driver msm8974_noc_driver = { .driver = { .name = "qnoc-msm8974", .of_match_table = msm8974_noc_of_match, + .sync_state = icc_sync_state, }, }; module_platform_driver(msm8974_noc_driver);