Skip to contentSkip to conversation

i2c: jz4780: Return error if clk_freq is set to 0

PATCH In review Axel Lin 2 participants 2 messages Apr 8, 2016

Subsystems (2)
lore
Share & tools
lore

Axel Lin

author
#0 lore raw

PATCH 1/1 i2c: jz4780: Return error if clk_freq is set to 0

Current code returns 0 in probe if clk_freq is set to 0. As a result, the probe success but the module does not work. Fix it.

Fixes 34cf2acdafaa ("i2c: jz4780: prevent potential division by zero")
---
 drivers/i2c/busses/i2c-jz4780.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/i2c/busses/i2c-jz4780.c +2 -0
index 597408f..0b3ba8d 100644
@@ -772,6 +772,8 @@ static int jz4780_i2c_probe(struct platform_device *pdev)
 				   &clk_freq);
 	if (ret || clk_freq == 0) {
 		dev_err(&pdev->dev, "clock-frequency not specified in DT");
+		if (ret == 0)
+			ret = -EINVAL;
 		goto err;
 	}
 
Signature · 1 line
2.1.4
#1 lore raw
Quoted 5 lines · Axel Lin

Current code returns 0 in probe if clk_freq is set to 0. As a result, the probe success but the module does not work. Fix it.

Fixes 34cf2acdafaa ("i2c: jz4780: prevent potential division by zero")

True, thanks for the pointer! However, I think we should also check i2c->speed directly. I'll send a patch right now. Please let me know if you agree on that one.