Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a8f82988 authored by Axel Lin's avatar Axel Lin Committed by Greg Kroah-Hartman
Browse files

i2c: sun6i-p2wi: Prevent potential division by zero



[ 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: default avatarAxel Lin <axel.lin@ingics.com>
Acked-by: default avatarBoris Brezillon <boris.brezillon@free-electrons.com>
Signed-off-by: default avatarWolfram Sang <wsa@kernel.org>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
parent 80876a07
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -202,6 +202,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;