Make sure that 'ret' is populated before we leave and check the variable which is actually used as a divisor. Add missing '\n' while we are here. Reported-by: Axel Lin <axel.lin@xxxxxxxxxx> Signed-off-by: Wolfram Sang <wsa@xxxxxxxxxxxxx> Fixes: 34cf2acdafaa ("i2c: jz4780: prevent potential division by zero") --- drivers/i2c/busses/i2c-jz4780.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/i2c/busses/i2c-jz4780.c b/drivers/i2c/busses/i2c-jz4780.c index 597408fc6834fc..ba14a863b451f9 100644 --- a/drivers/i2c/busses/i2c-jz4780.c +++ b/drivers/i2c/busses/i2c-jz4780.c @@ -770,12 +770,17 @@ static int jz4780_i2c_probe(struct platform_device *pdev) ret = of_property_read_u32(pdev->dev.of_node, "clock-frequency", &clk_freq); - if (ret || clk_freq == 0) { - dev_err(&pdev->dev, "clock-frequency not specified in DT"); + if (ret) { + dev_err(&pdev->dev, "clock-frequency not specified in DT\n"); goto err; } i2c->speed = clk_freq / 1000; + if (i2c->speed == 0) { + ret = -EINVAL; + dev_err(&pdev->dev, "clock-frequency minimum is 1000\n"); + goto err; + } jz4780_i2c_set_speed(i2c); dev_info(&pdev->dev, "Bus frequency is %d KHz\n", i2c->speed); -- 2.7.0 -- To unsubscribe from this list: send the line "unsubscribe linux-i2c" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html