From: Axel Lin <axel.lin@ingics.com>
To: Wolfram Sang <wsa@the-dreams.de>
Cc: "Uwe Kleine-König" <kernel@pengutronix.de>, linux-i2c@vger.kernel.org
Subject: [PATCH] i2c: efm32: Prevent potential division by zero
Date: Thu, 14 Apr 2016 15:42:54 +0800 [thread overview]
Message-ID: <1460619774.4294.1.camel@ingics.com> (raw)
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.
Signed-off-by: Axel Lin <axel.lin@ingics.com>
---
drivers/i2c/busses/i2c-efm32.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/i2c/busses/i2c-efm32.c b/drivers/i2c/busses/i2c-efm32.c
index 8eff627..394c695 100644
--- a/drivers/i2c/busses/i2c-efm32.c
+++ b/drivers/i2c/busses/i2c-efm32.c
@@ -389,7 +389,7 @@ static int efm32_i2c_probe(struct platform_device *pdev)
ddata->location = location;
ret = of_property_read_u32(np, "clock-frequency", &frequency);
- if (!ret) {
+ if (!ret && frequency != 0) {
dev_dbg(&pdev->dev, "using frequency %u\n", frequency);
} else {
frequency = 100000;
--
2.5.0
next reply other threads:[~2016-04-14 7:42 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-14 7:42 Axel Lin [this message]
2016-04-14 8:24 ` [PATCH] i2c: efm32: Prevent potential division by zero Uwe Kleine-König
2016-04-14 8:29 ` Axel Lin
2016-04-14 9:06 ` Uwe Kleine-König
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1460619774.4294.1.camel@ingics.com \
--to=axel.lin@ingics.com \
--cc=kernel@pengutronix.de \
--cc=linux-i2c@vger.kernel.org \
--cc=wsa@the-dreams.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.