* [PATCH] i2c: jz4780: really prevent potential division by zero
@ 2016-04-08 10:03 Wolfram Sang
2016-04-08 23:42 ` Axel Lin
0 siblings, 1 reply; 2+ messages in thread
From: Wolfram Sang @ 2016-04-08 10:03 UTC (permalink / raw)
To: linux-i2c; +Cc: Zubair Lutfullah Kakakhel, Axel Lin, Wolfram Sang
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@ingics.com>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
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
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] i2c: jz4780: really prevent potential division by zero
2016-04-08 10:03 [PATCH] i2c: jz4780: really prevent potential division by zero Wolfram Sang
@ 2016-04-08 23:42 ` Axel Lin
0 siblings, 0 replies; 2+ messages in thread
From: Axel Lin @ 2016-04-08 23:42 UTC (permalink / raw)
To: Wolfram Sang; +Cc: linux-i2c, Zubair Lutfullah Kakakhel
2016-04-08 18:03 GMT+08:00 Wolfram Sang <wsa@the-dreams.de>:
> 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@ingics.com>
> Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
> Fixes: 34cf2acdafaa ("i2c: jz4780: prevent potential division by zero")
Looks good to me.
Thanks
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-04-08 23:42 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-04-08 10:03 [PATCH] i2c: jz4780: really prevent potential division by zero Wolfram Sang
2016-04-08 23:42 ` Axel Lin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).