From: Andi Shyti <andi.shyti@samsung.com>
To: Krzysztof Kozlowski <krzk@kernel.org>, Mark Brown <broonie@kernel.org>
Cc: Javier Martinez Canillas <javier@osg.samsung.com>,
linux-samsung-soc@vger.kernel.org, linux-spi@vger.kernel.org,
linux-kernel@vger.kernel.org, Andi Shyti <andi.shyti@samsung.com>,
Andi Shyti <andi@etezian.org>
Subject: [PATCH 2/2] spi: s3c64xx: fix potential division by zero
Date: Tue, 07 Feb 2017 17:10:25 +0900 [thread overview]
Message-ID: <20170207081025.9671-2-andi.shyti@samsung.com> (raw)
In-Reply-To: <20170207081025.9671-1-andi.shyti@samsung.com>
Even though it's quite unlikely to happen in this particular
case, clk_get_rate can return '0' if sdd->src_clk is not set
properly. In that case we would have a clear division by '0'.
Check the return value of clk_get_rate and fail in case it
returns '0'.
This patch fixes '1397922 Division or modulo by zero' from
scan.coverity.com
Signed-off-by: Andi Shyti <andi.shyti@samsung.com>
---
drivers/spi/spi-s3c64xx.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/spi/spi-s3c64xx.c b/drivers/spi/spi-s3c64xx.c
index f6ea9ae047ec..a2ec07f44e33 100644
--- a/drivers/spi/spi-s3c64xx.c
+++ b/drivers/spi/spi-s3c64xx.c
@@ -811,6 +811,8 @@ static int s3c64xx_spi_setup(struct spi_device *spi)
/* Max possible */
speed = clk_get_rate(sdd->src_clk) / 2 / (0 + 1);
+ if (!speed)
+ goto setup_exit;
if (spi->max_speed_hz > speed)
spi->max_speed_hz = speed;
--
2.11.0
next prev parent reply other threads:[~2017-02-07 8:11 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CGME20170207081032epcas5p30d99ec5cfc68b71cd46bd0218101c22b@epcas5p3.samsung.com>
2017-02-07 8:10 ` [PATCH 1/2] spi: s3c64xx: fix potential segmentation fault Andi Shyti
[not found] ` <CGME20170207081032epcas5p3af837bbe00278da4029fc7bb9eba6961@epcas5p3.samsung.com>
2017-02-07 8:10 ` Andi Shyti [this message]
2017-02-07 20:49 ` [PATCH 2/2] spi: s3c64xx: fix potential division by zero Krzysztof Kozlowski
2017-02-08 4:19 ` Andi Shyti
2017-02-07 20:45 ` [PATCH 1/2] spi: s3c64xx: fix potential segmentation fault Krzysztof Kozlowski
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=20170207081025.9671-2-andi.shyti@samsung.com \
--to=andi.shyti@samsung.com \
--cc=andi@etezian.org \
--cc=broonie@kernel.org \
--cc=javier@osg.samsung.com \
--cc=krzk@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-samsung-soc@vger.kernel.org \
--cc=linux-spi@vger.kernel.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®