From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 3031DC77B73 for ; Tue, 30 May 2023 18:51:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=6ZeLjcNVbuVR4KBipgnz5/EvzY/TeKUsbDGFye3riI0=; b=BNKD0z7Su708F5 3a/vM8N2SiMZ+8byGumoMekeHbYC5TbL85EFLdIUY9Bf5drlO6zsRd1SqFi2ltUTLcrjU86ySeNq5 7ulzjX1Rtd0XTxv6TD9XnhJV1nI+i6Px6R1xInZ76jdqkMIMvD8X+NDX/A5SA6fhaR+qpX9Lodw67 8w1mBCZxDeEak1IK0CK8G0BR/nqDzprDcShdzLWTWeKNTObe8NWDSdQlDRF5GNS3HVUsrzUxYI4WB qIbzY64Y02mdjbQAd5T+4bzXSHYijbru9bbsGKpjSqofo8Zbr4Cz/YLB96phPglwh9cnqA5IlDsc+ 5qoLZCi8lE9BI2nEAR7w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q44Qi-00EuqR-2X; Tue, 30 May 2023 18:50:48 +0000 Received: from dfw.source.kernel.org ([2604:1380:4641:c500::1]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1q44Qg-00EupJ-16 for linux-arm-kernel@lists.infradead.org; Tue, 30 May 2023 18:50:47 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id E3B9E61AC8; Tue, 30 May 2023 18:50:39 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A6ABBC4339B; Tue, 30 May 2023 18:50:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1685472639; bh=IZndPRsXdrvOnJb0ewXcTHzPGDycIf5ne3eEnx8Ld9E=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=SobdW6evDpNp5XKzU2RTYcxgG6l3SzTGzHCt5xrkeFknfGnlWzrVbG7cP1lPwqiaP 0FfyQurrDzUSnsieubT4XEnyDT97hyJQtHJCkBqJnG0CujgiOkILFbSLR7zDNG2zfY T0hRclOsh62yzX4bY8+RHhL+htMASIgNqijM8KK+6H5Ht8sJdg5Dv6cDj1Ps1Pey0s oVJeNXw6Y551qe82DQGWsaSS1fwR6MjgToppxj6pwlWvbH7FwDh/O6iZVWx7bZhddo NXJlP8NoZygP29UsklAodVhproIJN3PrDjO2Fv1p9/2bdMZGxOAU7sWK64Gi/PyPsy 8Ln+mS7SaCOWw== Date: Tue, 30 May 2023 20:50:36 +0200 From: Andi Shyti To: carlos.song@nxp.com Cc: aisheng.dong@nxp.com, shawnguo@kernel.org, s.hauer@pengutronix.de, kernel@pengutronix.de, festevam@gmail.com, xiaoning.wang@nxp.com, haibo.chen@nxp.com, linux-imx@nxp.com, linux-i2c@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] i2c: imx-lpi2c: fix type char overflow issue when calculating the clock cycle Message-ID: <20230530185036.ggep3pv7booqtb6b@intel.intel> References: <20230529080251.3614380-1-carlos.song@nxp.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20230529080251.3614380-1-carlos.song@nxp.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230530_115046_445752_BA5407C7 X-CRM114-Status: GOOD ( 19.47 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Mon, May 29, 2023 at 04:02:51PM +0800, carlos.song@nxp.com wrote: > From: Clark Wang > > Claim clkhi and clklo as integer type to avoid possible calculation > errors caused by data overflow. > > Fixes: a55fa9d0e42e ("i2c: imx-lpi2c: add low power i2c bus driver") > Signed-off-by: Clark Wang > Signed-off-by: Carlos Song > --- > drivers/i2c/busses/i2c-imx-lpi2c.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/drivers/i2c/busses/i2c-imx-lpi2c.c b/drivers/i2c/busses/i2c-imx-lpi2c.c > index 40a4420d4c12..7dd33564cbe1 100644 > --- a/drivers/i2c/busses/i2c-imx-lpi2c.c > +++ b/drivers/i2c/busses/i2c-imx-lpi2c.c > @@ -211,8 +211,8 @@ static void lpi2c_imx_stop(struct lpi2c_imx_struct *lpi2c_imx) > /* CLKLO = I2C_CLK_RATIO * CLKHI, SETHOLD = CLKHI, DATAVD = CLKHI/2 */ > static int lpi2c_imx_config(struct lpi2c_imx_struct *lpi2c_imx) > { > - u8 prescale, filt, sethold, clkhi, clklo, datavd; > - unsigned int clk_rate, clk_cycle; > + u8 prescale, filt, sethold, datavd; > + unsigned int clk_rate, clk_cycle, clkhi, clklo; looks OK. Reviewed-by: Andi Shyti there is, though, another part I would take care of, this bit: clklo = clk_cycle - clkhi; if (clklo < 64) break; It might be unlikely, but if "clk_cycle > clkhi" then all the calculation. Do you mind adding a check: if (unlikely(clk_cycle > clkhi)) break; Andi > enum lpi2c_imx_pincfg pincfg; > unsigned int temp; > > -- > 2.34.1 > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel