diff options
author | Masahiro Yamada <yamada.masahiro@socionext.com> | 2015-11-30 18:53:36 +0900 |
---|---|---|
committer | Wolfram Sang <wsa@the-dreams.de> | 2015-12-14 10:59:46 +0100 |
commit | 51549c087f2eb5788de48a7278c3eb169d66f554 (patch) | |
tree | aaca1adeded14db1cd16b16d8e67595c4211f890 /drivers/i2c | |
parent | ac9b91f39d86f04eeacfccb6b6113b1ffa001ec1 (diff) | |
download | linux-51549c087f2eb5788de48a7278c3eb169d66f554.tar.bz2 |
i2c: uniphier_f: error out if bus speed is zero
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>
Diffstat (limited to 'drivers/i2c')
-rw-r--r-- | drivers/i2c/busses/i2c-uniphier-f.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/drivers/i2c/busses/i2c-uniphier-f.c b/drivers/i2c/busses/i2c-uniphier-f.c index 67109e1d66c3..f3e5ff8522f0 100644 --- a/drivers/i2c/busses/i2c-uniphier-f.c +++ b/drivers/i2c/busses/i2c-uniphier-f.c @@ -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; |