From patchwork Tue Sep 29 10:57:50 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 262955 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9D7D1C47426 for ; Tue, 29 Sep 2020 12:32:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 556212083B for ; Tue, 29 Sep 2020 12:32:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1601382767; bh=UjL3BskRwLRof0uTzYp0icPKMM6aheG/65eSWsggAEc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=XN/dfmAEvSpAFPlU1HKbh3SyI7JhaAxwfGOivzOdCELdk0kYrBHmtRLY/2wSS6e6z yGLH27BSqENVlM0uxiyHPd0oIMw4eiV9ghPOR71f9nmeofduS2B57M2i1gW7m5QAC6 QiApjYz1vYvNpjkwTAi7lPbReLvgXvZWBVQ/AfO8= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732781AbgI2McR (ORCPT ); Tue, 29 Sep 2020 08:32:17 -0400 Received: from mail.kernel.org ([198.145.29.99]:37026 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729546AbgI2LXB (ORCPT ); Tue, 29 Sep 2020 07:23:01 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id C9A4521D7D; Tue, 29 Sep 2020 11:20:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1601378452; bh=UjL3BskRwLRof0uTzYp0icPKMM6aheG/65eSWsggAEc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Vj880f5K9LT5Di0DAcHqnMhqHpNdbDwkZYbLUGJIpK8KLOXLo7XmzPDJ+zM/KsqPW 1tGT8UdlZfvQxG0zHg6OJig7Tyt+xACisoKiqxizrV5viBAL/cLzm+N0PpIfYBkF5V 1x3QR7UXqudrB3rhMo7Gx9V5Bt+EyK5CspB7wIyA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Chanwoo Choi , Peter Geis , Dmitry Osipenko , Sasha Levin Subject: [PATCH 4.19 019/245] PM / devfreq: tegra30: Fix integer overflow on CPUs freq max out Date: Tue, 29 Sep 2020 12:57:50 +0200 Message-Id: <20200929105947.929201703@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200929105946.978650816@linuxfoundation.org> References: <20200929105946.978650816@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Dmitry Osipenko [ Upstream commit 53b4b2aeee26f42cde5ff2a16dd0d8590c51a55a ] There is another kHz-conversion bug in the code, resulting in integer overflow. Although, this time the resulting value is 4294966296 and it's close to ULONG_MAX, which is okay in this case. Reviewed-by: Chanwoo Choi Tested-by: Peter Geis Signed-off-by: Dmitry Osipenko Signed-off-by: Chanwoo Choi Signed-off-by: Sasha Levin --- drivers/devfreq/tegra-devfreq.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/devfreq/tegra-devfreq.c b/drivers/devfreq/tegra-devfreq.c index 06768074d2d82..479d9575e1245 100644 --- a/drivers/devfreq/tegra-devfreq.c +++ b/drivers/devfreq/tegra-devfreq.c @@ -80,6 +80,8 @@ #define KHZ 1000 +#define KHZ_MAX (ULONG_MAX / KHZ) + /* Assume that the bus is saturated if the utilization is 25% */ #define BUS_SATURATION_RATIO 25 @@ -180,7 +182,7 @@ struct tegra_actmon_emc_ratio { }; static struct tegra_actmon_emc_ratio actmon_emc_ratios[] = { - { 1400000, ULONG_MAX }, + { 1400000, KHZ_MAX }, { 1200000, 750000 }, { 1100000, 600000 }, { 1000000, 500000 },