From patchwork Wed Oct 30 14:54:57 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Colin King X-Patchwork-Id: 11219695 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1FA4B112B for ; Wed, 30 Oct 2019 14:55:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id F006920856 for ; Wed, 30 Oct 2019 14:55:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726713AbfJ3OzE (ORCPT ); Wed, 30 Oct 2019 10:55:04 -0400 Received: from youngberry.canonical.com ([91.189.89.112]:50027 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726175AbfJ3OzE (ORCPT ); Wed, 30 Oct 2019 10:55:04 -0400 Received: from 1.general.cking.uk.vpn ([10.172.193.212] helo=localhost) by youngberry.canonical.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1iPpNB-0000Y6-Dj; Wed, 30 Oct 2019 14:54:57 +0000 From: Colin King To: Kukjin Kim , Krzysztof Kozlowski , Sylwester Nawrocki , linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org Cc: kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH][next] soc: samsung: exynos-asv: fix potential overflow in multiply Date: Wed, 30 Oct 2019 14:54:57 +0000 Message-Id: <20191030145457.10120-1-colin.king@canonical.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Sender: linux-samsung-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org From: Colin Ian King The multiplication of opp_freq by MHZ is performed using unsigned int multiplication however the result is being passed into a function where the frequency is an unsigned long, so there is an expectation that the result won't fit into an unsigned int. Fix any potential integer overflow my making opp_freq an unsigned long. Also change from %u to %lu format specifiers Addresses-Coverity: ("Unintentional integer overflow") Fixes: 5ea428595cc5 ("soc: samsung: Add Exynos Adaptive Supply Voltage driver") Signed-off-by: Colin Ian King --- drivers/soc/samsung/exynos-asv.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/soc/samsung/exynos-asv.c b/drivers/soc/samsung/exynos-asv.c index 8abf4dfaa5c5..d66fc74379a3 100644 --- a/drivers/soc/samsung/exynos-asv.c +++ b/drivers/soc/samsung/exynos-asv.c @@ -30,7 +30,7 @@ static int exynos_asv_update_cpu_opps(struct exynos_asv *asv, { struct exynos_asv_subsys *subsys = NULL; struct dev_pm_opp *opp; - unsigned int opp_freq; + unsigned long opp_freq; int i; for (i = 0; i < ARRAY_SIZE(asv->subsys); i++) { @@ -51,7 +51,7 @@ static int exynos_asv_update_cpu_opps(struct exynos_asv *asv, opp = dev_pm_opp_find_freq_exact(cpu, opp_freq * MHZ, true); if (IS_ERR(opp)) { - dev_info(asv->dev, "cpu%d opp%d, freq: %u missing\n", + dev_info(asv->dev, "cpu%d opp%d, freq: %lu missing\n", cpu->id, i, opp_freq); continue; @@ -68,11 +68,11 @@ static int exynos_asv_update_cpu_opps(struct exynos_asv *asv, new_volt, new_volt, new_volt); if (ret < 0) dev_err(asv->dev, - "Failed to adjust OPP %u Hz/%u uV for cpu%d\n", + "Failed to adjust OPP %lu Hz/%u uV for cpu%d\n", opp_freq, new_volt, cpu->id); else dev_dbg(asv->dev, - "Adjusted OPP %u Hz/%u -> %u uV, cpu%d\n", + "Adjusted OPP %lu Hz/%u -> %u uV, cpu%d\n", opp_freq, volt, new_volt, cpu->id); }