From patchwork Sat May 4 00:49:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Peng Fan (OSS)" X-Patchwork-Id: 13653709 Received: from EUR03-AM7-obe.outbound.protection.outlook.com (mail-am7eur03on2088.outbound.protection.outlook.com [40.107.105.88]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 136401AACB for ; Sat, 4 May 2024 00:41:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.105.88 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714783305; cv=fail; b=fbphU37qJFspJH4QMGTgZxYs8hMrLf8YJmPRMnikbdWUF6FZkGRbr0WKtrTCO4IDW946igv6+CHGBLIcd29Z7l21LiU6mHJC8NedgFZIlQMc+F7oLwEiuYHSnoLf0l52cQUduerG2Qo0c7o8Eo4ikDYnZotmYAIh9VjjYu6cG4k= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714783305; c=relaxed/simple; bh=ALKKAIPLFtEvvSEnwT7GaTl1G+mKLBFTKWPRdBXUeVk=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=qpI8saA/YZ+K+qggpWbFgDu8/uCQ0RG7bTYu3tm5XErQIcWBFcczwn0bQj3G4f3ObKmFfREgkGM+5rfy8IKYK3/EAJ5Fx8MCVcEtt0EegsbNmUehG2S7qa0r87eER9dDivU+IPIQwPVhICahlBxatKZDt0KbxA0++TxQXK/d6Fk= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=oss.nxp.com; spf=pass smtp.mailfrom=oss.nxp.com; dkim=pass (1024-bit key) header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.b=YTPSITgO; arc=fail smtp.client-ip=40.107.105.88 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=oss.nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.b="YTPSITgO" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CdXXZ+fqxUnZuecoBlyRWhPPrFbGqJLCUx7+sc8UIytdJX3TpVrsp8yDeFQ/W1fp2RgIO6wG3c0N0oEA4laKa0SkNSVRKYDKGBHoAXxLQAHpD5jrRFIuR4f5boyPO2ywhxkyW5T2vEIXNNhBBZ47mprICR8NLSxZj2oyT+DzivQ3PBB/6gtAX0+l+t7sAmqAEe/yj729NDePCqlNjXs/doAu8fAY1xJVeLwVQkujHcxgGhcF40KLYsUEoLcVGKI9+fb5/Ts19bVYox8H931b4GiXM/7NQsx/eswUFgOIS9TlAk0FImPqDaKCocwqdm9uXIWizk/JJoRbxvhfEG4Vuw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Gd6H0t/yI/bSoUA0/9la81Hj7KLRUVbJaaIyMyJ4tb4=; b=Kz32p+dufuC2WnmpECJ6bAsPEIXovRKfKDQze2vzYYnzgAoSZxG/0LJ0IKq95GTn3b2yBQ32Do/WbuhqoAPpZ4Zj7ojpb2ZKoLnDya1yE5eL8qtVpL2KR+sMkVTvU4afXfTz1faaul95P7w/wT/BrA1VufHOZVwSvT4J7BXgjQXceNzPGlLuzqKvkmyzKE28Nlxyy/mK0FvHO9Kj0I38bM2Uu1B5/UqFKEUaT3sGMXriQ3VEOwfKPJDZPlLkdwbqIf12/pbKAc4OseK1fgNl+Q7ogm1ktIK2NjwM/eIYZfgnH8uJLtqBfxv5S4RbeJZjc5yGjkIVZLf+j1dtdUqX6Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NXP1.onmicrosoft.com; s=selector2-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Gd6H0t/yI/bSoUA0/9la81Hj7KLRUVbJaaIyMyJ4tb4=; b=YTPSITgOd3akPj0oOnAfA/adnGYWU/jO/betVZMAttbHcYv2R+ZBpuvnfj9AdOn1hrD02XncqWyYpJ2lxxESBPhO/vBtTkx2d04aYDspuku/paUzuNgtfQ0Y69VxHKrLvPbDLlu9JFv3z0bAeeu4Wen1Acj7bmn5yEaeLCt1Weg= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oss.nxp.com; Received: from DU0PR04MB9417.eurprd04.prod.outlook.com (2603:10a6:10:358::11) by PA4PR04MB7726.eurprd04.prod.outlook.com (2603:10a6:102:ea::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7544.29; Sat, 4 May 2024 00:41:41 +0000 Received: from DU0PR04MB9417.eurprd04.prod.outlook.com ([fe80::d30b:44e7:e78e:662d]) by DU0PR04MB9417.eurprd04.prod.outlook.com ([fe80::d30b:44e7:e78e:662d%4]) with mapi id 15.20.7544.029; Sat, 4 May 2024 00:41:41 +0000 From: "Peng Fan (OSS)" Date: Sat, 04 May 2024 08:49:00 +0800 Subject: [PATCH 07/18] clk: imx: pll14xx: potential integer overflow eliminated by casting to u64 Message-Id: <20240504-imx-clk-v1-7-f7915489d58d@nxp.com> References: <20240504-imx-clk-v1-0-f7915489d58d@nxp.com> In-Reply-To: <20240504-imx-clk-v1-0-f7915489d58d@nxp.com> To: Abel Vesa , Michael Turquette , Stephen Boyd , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , Jacky Bai , Ye Li , Dong Aisheng Cc: linux-clk@vger.kernel.org, imx@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Abel Vesa , Peng Fan , Florin Pavelescu , Viorel Suman X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1714783747; l=1012; i=peng.fan@nxp.com; s=20230812; h=from:subject:message-id; bh=2UdxVIeKUK80+gL9caamcVMcYBZoguh0p2StT5CJdjU=; b=mAWBjvNWQhykSMMFGDAo5tfYl/Ef1TVTWQ/b1pc2IojjxoOMZdo+qn6NZ8QaxHr9aXGVayd7v Q0i60dKL0cKDgxO5nNpxRvuLFOT4Q9f3lOZgdG0ldocHmY71YPh30+G X-Developer-Key: i=peng.fan@nxp.com; a=ed25519; pk=I4sJg7atIT1g63H7bb5lDRGR2gJW14RKDD0wFL8TT1g= X-ClientProxiedBy: SI1PR02CA0055.apcprd02.prod.outlook.com (2603:1096:4:1f5::16) To DU0PR04MB9417.eurprd04.prod.outlook.com (2603:10a6:10:358::11) Precedence: bulk X-Mailing-List: imx@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU0PR04MB9417:EE_|PA4PR04MB7726:EE_ X-MS-Office365-Filtering-Correlation-Id: cf4feb8b-cbeb-4ead-615b-08dc6bd2f71a X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|7416005|52116005|366007|1800799015|376005|921011|38350700005; X-Microsoft-Antispam-Message-Info: =?ut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Fi8wDdbt/lKsV8+dFQaX89r?= =?utf-8?q?L+Pn+dnFjERKYwH+VGOvBpIH0CO/wgGOIYLnDkbx8ilcFXI4EB9xhdyUnTMq/yxyu?= =?utf-8?q?sUj9X+GihuiYYZbfwcTfe2ZSPHeCjuRw0uYRC9NYJt/HkEWpmf1/cdZk7bAGsYyPz?= =?utf-8?q?gwgjAHNpV8PgZ9gxDZBgk/63EDxiLNKGFkPMDupmHDtMmqU4EW4hX2SenLskf5hOk?= =?utf-8?q?17r9/8KpZR+NG9vuY3eh1oY51QTVq6V1XTWL7LDTqRML7mqK2dkwsOTuEGsenyMPB?= =?utf-8?q?bwUZtkysArIvsqgnNbhDgUTTOOFlfLCc5LQOUWtzsqaBDNXsrkj+x99ntAlhCd/Bp?= =?utf-8?q?+jKdb55e2H4WoR9EfTFnqtA0FKJVW9zNCSuc2Jbg1Ax3B4lQTbaCaROEV+WiZsjNa?= =?utf-8?q?SKxwss6OqoenmQLpol9wEeLajY6c9roudl71DHvTkUJkZLtDUVz25b60=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DU0PR04MB9417.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(7416005)(52116005)(366007)(1800799015)(376005)(921011)(38350700005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?AiD6OOpbeQuqP8+4FXi0nsb9jeGK?= =?utf-8?q?bwgkNO7cctYCUwteDC7HwMTIvDFt2hxeD0+Pk8OwZemjNVF8oePWzWNhnMDnNj2Db?= =?utf-8?q?IvBn+uKfepQokqu+z1VJS4RS8wQQJbF9kW3MNBs+spahqJysTquO8N/rGlgz+6hGI?= =?utf-8?q?ZWBHTFz6gq813v2e1kEU3wcPLLwUxEmi79NTLaH8Cpez8mHpjGiHduNtbYXEzRE60?= =?utf-8?q?VM/tPy9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qcEzaTv1cCl72je2CQK07CyvoQAa6D/mRry4M6DVCjcDXXAUU?= =?utf-8?q?G3xKM4/STTuBb3cCNccG0yq7kZOI9CAhrKPTJUsrpFuZI8Xrh6LguuC2w8aI4PLPK?= =?utf-8?q?7G23VI9K0WijwgjVZz1uuzNi+/YyNWLucp3r9rSe04Yhmtp5tjWarADPCmHs+mFny?= =?utf-8?q?8UGaP3LrqSySbjCMxbivjOK5SdTVK+z46rJQUy7lTTJIOIzFvQ5hRx+fvv9BLmyHE?= =?utf-8?q?v97Q4twQzwnZaykxiXV7IdUuginruDjArU/Ziv4A2zQAKLP+4+joqksM6uJNi+KPI?= =?utf-8?q?Lt+LYwkK9Z+BuMrL//DWSvIbu9W3FcBq4U4WdNh/hcTlhfyWrr4C0Da/yBqTHd9SM?= =?utf-8?q?zTSH+WP7GoVhJVYBkus9/xeyCYkRgzVatkY9ereoVZ22ReA6hg8HvPJ7vaAHkZJfc?= =?utf-8?q?wEhFZor1bNf6?= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: cf4feb8b-cbeb-4ead-615b-08dc6bd2f71a X-MS-Exchange-CrossTenant-AuthSource: DU0PR04MB9417.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 May 2024 00:41:41.3516 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 9+HsixEc4V9jtZdHKnMuJjLkDUP1W3YovuQgWleVt96+zD7bgI27hR1VCxTGxOLcxayfyr0jG04oji6FWsLAsA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA4PR04MB7726 From: Florin Pavelescu Cast to u64, so that multiplications and additions will be done in 64-bit arithmetic (and the results will also be 64-bit) and the possibility of integer overflow is eliminated. Fix Unintentional integer overflow reported by Coverity Reviewed-by: Viorel Suman Signed-off-by: Florin Pavelescu Signed-off-by: Peng Fan --- drivers/clk/imx/clk-pll14xx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/clk/imx/clk-pll14xx.c b/drivers/clk/imx/clk-pll14xx.c index 6b2c849f8b71..78eedb1f4a79 100644 --- a/drivers/clk/imx/clk-pll14xx.c +++ b/drivers/clk/imx/clk-pll14xx.c @@ -118,7 +118,7 @@ static long pll14xx_calc_rate(struct clk_pll14xx *pll, int mdiv, int pdiv, u64 fout = prate; /* fout = (m * 65536 + k) * Fin / (p * 65536) / (1 << sdiv) */ - fout *= (mdiv * 65536 + kdiv); + fout *= ((u64)mdiv * 65536 + (u64)kdiv); pdiv *= 65536; do_div(fout, pdiv << sdiv);