From patchwork Fri Nov 6 14:48:47 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Georgi Djakov X-Patchwork-Id: 320790 Delivered-To: patch@linaro.org Received: by 2002:a92:7b12:0:0:0:0:0 with SMTP id w18csp1364596ilc; Fri, 6 Nov 2020 06:48:48 -0800 (PST) X-Google-Smtp-Source: ABdhPJxKa0CoGNyr1uX+rm31fcsxdfHvEyCN6RLhpk2/BGKgo9HOhqgOydHOtKbo98qbfkraLUCs X-Received: by 2002:a17:906:1d50:: with SMTP id o16mr2432689ejh.145.1604674127907; Fri, 06 Nov 2020 06:48:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604674127; cv=none; d=google.com; s=arc-20160816; b=jgy7t4iRBN1ADpxU/OgDO3mXsW6yYIopXqk2yKctQjzKJLBW6g1ip4Rab3TtN5uAKM LsAfvHVZIcI1xTWBpwnWwVUHrVXyWhaWpqBlgQtD4Mah6zvRIWWJ4tijRQilicMKlKIo OF7gJeZpjnSudf4i9rrrFsQI8ttZUdmP89O2tdFJUL90UF4K3FzKjr69TV0DMVrZUBgf ZRV7fNJ1xVmGvz32xfVvH1Bo11tqE7b7I+5sS4kL8SHCSZ5k483Xe84sMMS4D38i0e6F tc5Ujv5BkmQ/jY+5/x7qNROQov6WhwTOlQxsYgLTU1n7XCPlEKWp49zcNJ95wGgwDeOh NYQw== 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=RdP6pyFnp6oULtmvD6Zqf0XfTytrBDyX/vESPqEDQQBUPOCTsqOn0g6tdFBC4QRP+9 tBAi5ZyBgkA8QHuWAH8U8X1w+cFOR5W4iOiLUQ4aiKEbEWApIxyiGLLMSdJ2pBPrJwLS 2V6XPlRhhJpIHZw/7uGCytL2lUgboHXg6qJ0fzvbo6KeowwHWVOGHMpVCzgWBLSmUpV5 LBisNRSctbqpEOukWpwIixrQM/MhUfKYluCnxFP1O5Li8Z2DJqDu07nLg5/40S/ysMy2 2V6PZ5tjCUn1b8RPNtO3GVWbCvMl8S0q96aL93ad7OH+ktb1q1wlv4lBqvpyqQjb156S Y5Lg== 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-pm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-pm-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 h20si1135800edw.304.2020.11.06.06.48.47; Fri, 06 Nov 2020 06:48:47 -0800 (PST) Received-SPF: pass (google.com: domain of linux-pm-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-pm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-pm-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 S1727498AbgKFOsq (ORCPT + 9 others); Fri, 6 Nov 2020 09:48:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46960 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727497AbgKFOsq (ORCPT ); Fri, 6 Nov 2020 09:48:46 -0500 Received: from mail-wr1-x441.google.com (mail-wr1-x441.google.com [IPv6:2a00:1450:4864:20::441]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 635BDC0613D4 for ; Fri, 6 Nov 2020 06:48:46 -0800 (PST) Received: by mail-wr1-x441.google.com with SMTP id w1so1598374wrm.4 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=Bz1TL+Rj/fsEWPs125mfxs0eNiinthCEn5R0GbMD6961JwRZzgyayoTYK3FRjsWWFF Y7czje3Ayn+ZxUttDRsvz3Abe8TlZ2JKvlSPrvzWCVW+Jq+j+JfVubr9Q4W2U3CIXtTz PafjQd/g1wSmtE+BtSqaul1wafcyCk8KbYyidD3QT4zYDpuGUHlilccoCXsQaASKFb1Z HfXIIJ9zBfNRgVacm56uduoYGoaD25VG1LSS+SBycQkGNZnL1n8dgqak8gAQEoSSUnyb xVmvmQ1h0PAMS6qNobRiLUTO4vU+fE4jFXk2BTfKb1UJLoqoThx+ccPataa9hx19KvEA Ym+A== X-Gm-Message-State: AOAM533OIC9y+rB7OZF1MzQ1bBE1Ca7ng3sarkloJEC+aCjN9M9JxWrt ud2P1KfdOaQMeOXlGWshAEW4NUd4GPvUuQ== 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 Precedence: bulk List-ID: X-Mailing-List: linux-pm@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(+) Reviewed-by: Brian Masney 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);