[RFT,1/2] i2c: sirf: Prevent potential division by zero
diff mbox

Message ID 1460508570.6009.1.camel@ingics.com
State New
Headers show

Commit Message

Axel Lin April 13, 2016, 12:49 a.m. UTC
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. Since the clock-frequency
property is optional in current code, use SIRFSOC_I2C_DEFAULT_SPEED
instead if clock-frequency is set to 0 in a DT.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
---
 drivers/i2c/busses/i2c-sirf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Patch
diff mbox

diff --git a/drivers/i2c/busses/i2c-sirf.c b/drivers/i2c/busses/i2c-sirf.c
index 792a42b..82743e4 100644
--- a/drivers/i2c/busses/i2c-sirf.c
+++ b/drivers/i2c/busses/i2c-sirf.c
@@ -353,7 +353,7 @@  static int i2c_sirfsoc_probe(struct platform_device *pdev)
 
 	err = of_property_read_u32(pdev->dev.of_node,
 		"clock-frequency", &bitrate);
-	if (err < 0)
+	if (err < 0 || bitrate == 0)
 		bitrate = SIRFSOC_I2C_DEFAULT_SPEED;
 
 	/*