Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1279738
| Path | csiph.com!eternal-september.org!feeder.eternal-september.org!aioe.org!bofh.it!news.nic.it!robomod |
|---|---|
| From | Masahiro Yamada <yamada.masahiro@socionext.com> |
| Newsgroups | linux.kernel |
| Subject | [PATCH 2/4] i2c: uniphier: error out if bus speed is zero |
| Date | Mon, 30 Nov 2015 11:00:01 +0100 |
| Message-ID | <qAtpv-1UE-3@gated-at.bofh.it> (permalink) |
| References | <qAtpv-1UE-1@gated-at.bofh.it> |
| X-Original-To | linux-i2c@vger.kernel.org |
| X-Nifty-Srcip | [153.142.97.90] |
| X-Mailer | git-send-email 1.9.1 |
| Sender | robomod@news.nic.it |
| List-ID | <linux-kernel.vger.kernel.org> |
| X-Mailing-List | linux-kernel@vger.kernel.org |
| Approved | robomod@news.nic.it |
| Lines | 34 |
| Organization | linux.* mail to news gateway |
| X-Original-Cc | Masahiro Yamada <yamada.masahiro@socionext.com>, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Wolfram Sang <wsa@the-dreams.de> |
| X-Original-Date | Mon, 30 Nov 2015 18:53:34 +0900 |
| X-Original-Message-ID | <1448877216-32286-3-git-send-email-yamada.masahiro@socionext.com> |
| X-Original-References | <1448877216-32286-1-git-send-email-yamada.masahiro@socionext.com> |
| X-Original-Sender | linux-kernel-owner@vger.kernel.org |
| Xref | csiph.com linux.kernel:1279738 |
Show key headers only | View raw
There is code to divide by "bus_speed" some lines below.
To eliminate the possibility of division by zero, bail out if
"clock-frequency" is specified as zero.
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
---
drivers/i2c/busses/i2c-uniphier.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/drivers/i2c/busses/i2c-uniphier.c b/drivers/i2c/busses/i2c-uniphier.c
index 2b2c20b..1f4f3f5 100644
--- a/drivers/i2c/busses/i2c-uniphier.c
+++ b/drivers/i2c/busses/i2c-uniphier.c
@@ -327,6 +327,11 @@ static int uniphier_i2c_clk_init(struct device *dev,
if (of_property_read_u32(np, "clock-frequency", &bus_speed))
bus_speed = UNIPHIER_I2C_DEFAULT_SPEED;
+ if (!bus_speed) {
+ dev_err(dev, "clock-freqyency should not be zero\n");
+ return -EINVAL;
+ }
+
if (bus_speed > UNIPHIER_I2C_MAX_SPEED)
bus_speed = UNIPHIER_I2C_MAX_SPEED;
--
1.9.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH 0/4] i2c: uniphier: add minor sanity checks to i2c-uniphier/i2c-uniphier-f Masahiro Yamada <yamada.masahiro@socionext.com> - 2015-11-30 11:00 +0100 [PATCH 2/4] i2c: uniphier: error out if bus speed is zero Masahiro Yamada <yamada.masahiro@socionext.com> - 2015-11-30 11:00 +0100 [PATCH 4/4] i2c: uniphier_f: error out if bus speed is zero Masahiro Yamada <yamada.masahiro@socionext.com> - 2015-11-30 11:00 +0100 [PATCH 3/4] i2c: uniphier_f: error out if clock rate is zero Masahiro Yamada <yamada.masahiro@socionext.com> - 2015-11-30 11:00 +0100
csiph-web