Skip to content

Commit 5ac61d2

Browse files
AxelLinwsakernel
authored andcommitted
i2c: sun6i-p2wi: Prevent potential division by zero
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 <[email protected]> Acked-by: Boris Brezillon <[email protected]> Signed-off-by: Wolfram Sang <[email protected]>
1 parent d9387ed commit 5ac61d2

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

drivers/i2c/busses/i2c-sun6i-p2wi.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,11 @@ static int p2wi_probe(struct platform_device *pdev)
201201
return -EINVAL;
202202
}
203203

204+
if (clk_freq == 0) {
205+
dev_err(dev, "clock-frequency is set to 0 in DT\n");
206+
return -EINVAL;
207+
}
208+
204209
if (of_get_child_count(np) > 1) {
205210
dev_err(dev, "P2WI only supports one slave device\n");
206211
return -EINVAL;

0 commit comments

Comments
 (0)