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 D6F2E134B6; Sun, 12 Nov 2023 13:24:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Y9wDL/H+" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 403B7C43397; Sun, 12 Nov 2023 13:24:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1699795455; bh=molfT1j+T0iqaQ9D5qyzAkhYjMx29wLuP00lIpLbnlM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Y9wDL/H+skxUMhiuLLU+poJRokGZLx/KShCkacP8cJbuYSxrdX4YPauZzCugDLU5j /8nu0BXU9Shn4kS76dRXWrpzOCa4cbvMv4vtD56hddslpkmLwVM0GDkIhJoDEolb7/ gtE1cME5fBVJ6rwQroO0QFeexwuauEdndeiQhi5Fy05T7X/+4l8KN+4Rmsi+5HJNA2 1eZaUCTWCj0g5mL/GFadymK7WA3J2VBxhkat9eX90XX1y89Lf7N0ECxaVPX+gSyfCC cpOlfShem5dr0e69lyOFj/HpOOeVW1/O22BVCWB5SiWf4/R2b2qUOpkxd+DEt6WzU6 52yCi1eAbmQkw== 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.1 3/6] i2c: sun6i-p2wi: Prevent potential division by zero Date: Sun, 12 Nov 2023 08:23:58 -0500 Message-ID: <20231112132408.174499-3-sashal@kernel.org> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231112132408.174499-1-sashal@kernel.org> References: <20231112132408.174499-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-sunxi@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 6.1.62 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 9e3483f507ff5..f2ed13b551088 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