From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 0990114A9F; Sun, 12 Nov 2023 13:23:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="TEkfg4Vk" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 21078C433C9; Sun, 12 Nov 2023 13:23:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1699795434; bh=Xq/kzMbdpTOA74+EGlOh+LhuKvaYKKQT5nN3FI1YCg4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TEkfg4Vkipt0lpod+cxCs1UUm0ojxghxNEPncUudRPU8088njuoObB/+YZz5O8FwO l69MhKYUoq9pxtRHEKVXDTy4Ua+9/lwdhIGSdxjGuFBePShZAdzD5cWNS8WyCSrEn5 iwRGWs8KgDPePv0UiOyE0jZJOD3b07hRfrl2Kh0+P6cNtLOnSBGGQijv0cppifrB13 lNEks/mQDUdpnmE6suilU9WDqsED2hUc6W1yv8bCQQM5dsXq0t+EmVL6sQeVT41NAn e9DKRnEoP2mfCWP7xeezF1WLpF4cVOXJlbXxZUkCKR9bbj8h17bfSqSinBukH9r3tD Eh1rpqINqhO4A== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Axel Lin , Boris Brezillon , Wolfram Sang , Sasha Levin , andi.shyti@kernel.org, wens@csie.org, jernej.skrabec@gmail.com, samuel@sholland.org, linux-i2c@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev Subject: [PATCH AUTOSEL 6.5 4/7] i2c: sun6i-p2wi: Prevent potential division by zero Date: Sun, 12 Nov 2023 08:23:36 -0500 Message-ID: <20231112132347.174334-4-sashal@kernel.org> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231112132347.174334-1-sashal@kernel.org> References: <20231112132347.174334-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-i2c@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 6.5.11 Content-Transfer-Encoding: 8bit From: Axel Lin [ Upstream commit 5ac61d26b8baff5b2e5a9f3dc1ef63297e4b53e7 ] Make sure we don't OOPS in case clock-frequency is set to 0 in a DT. The variable set here is later used as a divisor. Signed-off-by: Axel Lin Acked-by: Boris Brezillon Signed-off-by: Wolfram Sang Signed-off-by: Sasha Levin --- drivers/i2c/busses/i2c-sun6i-p2wi.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/i2c/busses/i2c-sun6i-p2wi.c b/drivers/i2c/busses/i2c-sun6i-p2wi.c index fa6020dced595..85e035e7a1d75 100644 --- a/drivers/i2c/busses/i2c-sun6i-p2wi.c +++ b/drivers/i2c/busses/i2c-sun6i-p2wi.c @@ -201,6 +201,11 @@ static int p2wi_probe(struct platform_device *pdev) return -EINVAL; } + if (clk_freq == 0) { + dev_err(dev, "clock-frequency is set to 0 in DT\n"); + return -EINVAL; + } + if (of_get_child_count(np) > 1) { dev_err(dev, "P2WI only supports one slave device\n"); return -EINVAL; -- 2.42.0 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 AB6EBC4167D for ; Sun, 12 Nov 2023 13:24:24 +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:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=NlFfgs9GEvHXZbzkyA9r4CQk4RGn8GER0EMEkL+x85g=; b=ummEMaCbWS2t4H vO+bOHwP12Gw/dnn3XPsPn4nBHQdB/JAvP+v2XXsniad7zFB5F45QjYlTPSo2sY6aZRqOJ+pOUkJj Ximz3NlbDUfYvNzHuO/6BEC3QVmL8T7U67gQ5B69iR1G1a7ho0W23ZqbQX5xcvGbHkCzij9skO5Jn X2AtHBW/NRc1Hum3Ze+pl+jT5d/ryCy3IrN/RZBqjXjp6mwSIeeWtePa5zHXJTt7CsmEXPceUPFe0 36rTLWv2roOrXNiL3V1P5vUWEf9fuEe+paFuBqnniB3Rnh6qnMvKNk8VMFtz1JPxG/X4W2gZfu7eM bYQNnpjOh1NPvC0cFP8g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1r2ARW-00COyn-19; Sun, 12 Nov 2023 13:24:02 +0000 Received: from sin.source.kernel.org ([145.40.73.55]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1r2ART-00COwn-0l for linux-arm-kernel@lists.infradead.org; Sun, 12 Nov 2023 13:24:01 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 8B588CE0C6C; Sun, 12 Nov 2023 13:23:56 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 21078C433C9; Sun, 12 Nov 2023 13:23:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1699795434; bh=Xq/kzMbdpTOA74+EGlOh+LhuKvaYKKQT5nN3FI1YCg4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TEkfg4Vkipt0lpod+cxCs1UUm0ojxghxNEPncUudRPU8088njuoObB/+YZz5O8FwO l69MhKYUoq9pxtRHEKVXDTy4Ua+9/lwdhIGSdxjGuFBePShZAdzD5cWNS8WyCSrEn5 iwRGWs8KgDPePv0UiOyE0jZJOD3b07hRfrl2Kh0+P6cNtLOnSBGGQijv0cppifrB13 lNEks/mQDUdpnmE6suilU9WDqsED2hUc6W1yv8bCQQM5dsXq0t+EmVL6sQeVT41NAn e9DKRnEoP2mfCWP7xeezF1WLpF4cVOXJlbXxZUkCKR9bbj8h17bfSqSinBukH9r3tD Eh1rpqINqhO4A== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Axel Lin , Boris Brezillon , Wolfram Sang , Sasha Levin , andi.shyti@kernel.org, wens@csie.org, jernej.skrabec@gmail.com, samuel@sholland.org, linux-i2c@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev Subject: [PATCH AUTOSEL 6.5 4/7] i2c: sun6i-p2wi: Prevent potential division by zero Date: Sun, 12 Nov 2023 08:23:36 -0500 Message-ID: <20231112132347.174334-4-sashal@kernel.org> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231112132347.174334-1-sashal@kernel.org> References: <20231112132347.174334-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 6.5.11 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231112_052359_444185_65EC25DA X-CRM114-Status: GOOD ( 11.28 ) 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 From: Axel Lin [ Upstream commit 5ac61d26b8baff5b2e5a9f3dc1ef63297e4b53e7 ] Make sure we don't OOPS in case clock-frequency is set to 0 in a DT. The variable set here is later used as a divisor. Signed-off-by: Axel Lin Acked-by: Boris Brezillon Signed-off-by: Wolfram Sang Signed-off-by: Sasha Levin --- drivers/i2c/busses/i2c-sun6i-p2wi.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/i2c/busses/i2c-sun6i-p2wi.c b/drivers/i2c/busses/i2c-sun6i-p2wi.c index fa6020dced595..85e035e7a1d75 100644 --- a/drivers/i2c/busses/i2c-sun6i-p2wi.c +++ b/drivers/i2c/busses/i2c-sun6i-p2wi.c @@ -201,6 +201,11 @@ static int p2wi_probe(struct platform_device *pdev) return -EINVAL; } + if (clk_freq == 0) { + dev_err(dev, "clock-frequency is set to 0 in DT\n"); + return -EINVAL; + } + if (of_get_child_count(np) > 1) { dev_err(dev, "P2WI only supports one slave device\n"); return -EINVAL; -- 2.42.0 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel