]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
i2c: jz4780: prevent potential division by zero
authorWolfram Sang <wsa@the-dreams.de>
Sun, 3 Apr 2016 21:32:00 +0000 (23:32 +0200)
committerWolfram Sang <wsa@the-dreams.de>
Thu, 7 Apr 2016 19:13:38 +0000 (21:13 +0200)
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: Wolfram Sang <wsa@the-dreams.de>
drivers/i2c/busses/i2c-jz4780.c

index f325663c27c532645a1901a385ac6d52543e5ba5..597408fc6834fce711b89c26634ece928dfe9ad5 100644 (file)
@@ -770,7 +770,7 @@ static int jz4780_i2c_probe(struct platform_device *pdev)
 
        ret = of_property_read_u32(pdev->dev.of_node, "clock-frequency",
                                   &clk_freq);
-       if (ret) {
+       if (ret || clk_freq == 0) {
                dev_err(&pdev->dev, "clock-frequency not specified in DT");
                goto err;
        }