Return-Path: Received: from mail-by2nam03on0106.outbound.protection.outlook.com ([104.47.42.106]:22396 "EHLO NAM03-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S966565AbeCSQKH (ORCPT ); Mon, 19 Mar 2018 12:10:07 -0400 From: Sasha Levin To: "linux-kernel@vger.kernel.org" , "stable@vger.kernel.org" CC: Sudeep Holla , Michael Turquette , Stephen Boyd , Sasha Levin Subject: [PATCH AUTOSEL for 4.4 111/167] clk: scpi: fix return type of __scpi_dvfs_round_rate Date: Mon, 19 Mar 2018 16:07:41 +0000 Message-ID: <20180319160513.16384-111-alexander.levin@microsoft.com> References: <20180319160513.16384-1-alexander.levin@microsoft.com> In-Reply-To: <20180319160513.16384-1-alexander.levin@microsoft.com> Content-Language: en-US Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org List-ID: From: Sudeep Holla [ Upstream commit 7374aec95636ca39409545eba4ef5ff3125c2346 ] The frequencies above the maximum value of signed integer(i.e. 2^31 -1) will overflow with the current code. This patch fixes the return type of __scpi_dvfs_round_rate from 'int' to 'unsigned long'. Fixes: cd52c2a4b5c4 ("clk: add support for clocks provided by SCP(System Co= ntrol Processor)") Cc: Michael Turquette Cc: Stephen Boyd Signed-off-by: Sudeep Holla Signed-off-by: Stephen Boyd Signed-off-by: Sasha Levin --- drivers/clk/clk-scpi.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/clk/clk-scpi.c b/drivers/clk/clk-scpi.c index cd0f2726f5e0..c40445488d3a 100644 --- a/drivers/clk/clk-scpi.c +++ b/drivers/clk/clk-scpi.c @@ -71,15 +71,15 @@ static const struct clk_ops scpi_clk_ops =3D { }; =20 /* find closest match to given frequency in OPP table */ -static int __scpi_dvfs_round_rate(struct scpi_clk *clk, unsigned long rate= ) +static long __scpi_dvfs_round_rate(struct scpi_clk *clk, unsigned long rat= e) { int idx; - u32 fmin =3D 0, fmax =3D ~0, ftmp; + unsigned long fmin =3D 0, fmax =3D ~0, ftmp; const struct scpi_opp *opp =3D clk->info->opps; =20 for (idx =3D 0; idx < clk->info->count; idx++, opp++) { ftmp =3D opp->freq; - if (ftmp >=3D (u32)rate) { + if (ftmp >=3D rate) { if (ftmp <=3D fmax) fmax =3D ftmp; break; --=20 2.14.1