All of lore.kernel.org
 help / color / mirror / Atom feed
From: Axel Lin <axel.lin@ingics.com>
To: Wolfram Sang <wsa@the-dreams.de>
Cc: Barry Song <baohua@kernel.org>,
	Guoying Zhang <Guoying.Zhang@csr.com>,
	linux-i2c@vger.kernel.org
Subject: [RFT][PATCH 1/2] i2c: sirf: Prevent potential division by zero
Date: Wed, 13 Apr 2016 08:49:30 +0800	[thread overview]
Message-ID: <1460508570.6009.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. 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(-)

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;
 
 	/*
-- 
2.5.0

             reply	other threads:[~2016-04-13  0:49 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-13  0:49 Axel Lin [this message]
2016-04-13  0:54 ` [RFT][PATCH 2/2] i2c: sun6i-p2wi: Prevent potential division by zero Axel Lin
2016-04-13  7:49   ` Boris Brezillon

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=1460508570.6009.1.camel@ingics.com \
    --to=axel.lin@ingics.com \
    --cc=Guoying.Zhang@csr.com \
    --cc=baohua@kernel.org \
    --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.