i2c: uniphier_f: error out if bus speed is zero
authorMasahiro Yamada <yamada.masahiro@socionext.com>
Mon, 30 Nov 2015 09:53:36 +0000 (18:53 +0900)
committerWolfram Sang <wsa@the-dreams.de>
Mon, 14 Dec 2015 09:59:46 +0000 (10:59 +0100)
There is code to divide by "bus_speed" some lines below.
To eliminate the possibility of division by zero, bail out if
"clock-frequency" is specified as zero.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
drivers/i2c/busses/i2c-uniphier-f.c

index 67109e1d66c32ac57eccb6c4e50c260018c06879..f3e5ff8522f0af6ef77af252f3269114fe4b803e 100644 (file)
@@ -466,6 +466,11 @@ static int uniphier_fi2c_clk_init(struct device *dev,
        if (of_property_read_u32(np, "clock-frequency", &bus_speed))
                bus_speed = UNIPHIER_FI2C_DEFAULT_SPEED;
 
+       if (!bus_speed) {
+               dev_err(dev, "clock-freqyency should not be zero\n");
+               return -EINVAL;
+       }
+
        if (bus_speed > UNIPHIER_FI2C_MAX_SPEED)
                bus_speed = UNIPHIER_FI2C_MAX_SPEED;