Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1575460 > unrolled thread
| Started by | Andi Shyti <andi.shyti@samsung.com> |
|---|---|
| First post | 2017-02-07 09:20 +0100 |
| Last post | 2017-02-08 06:40 +0100 |
| Articles | 3 — 2 participants |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
[PATCH 2/2] spi: s3c64xx: fix potential division by zero Andi Shyti <andi.shyti@samsung.com> - 2017-02-07 09:20 +0100
Re: [PATCH 2/2] spi: s3c64xx: fix potential division by zero Krzysztof Kozlowski <krzk@kernel.org> - 2017-02-07 21:50 +0100
Re: [PATCH 2/2] spi: s3c64xx: fix potential division by zero Andi Shyti <andi.shyti@samsung.com> - 2017-02-08 06:40 +0100
| From | Andi Shyti <andi.shyti@samsung.com> |
|---|---|
| Date | 2017-02-07 09:20 +0100 |
| Subject | [PATCH 2/2] spi: s3c64xx: fix potential division by zero |
| Message-ID | <t89ai-kj-23@gated-at.bofh.it> |
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
[toc] | [next] | [standalone]
| From | Krzysztof Kozlowski <krzk@kernel.org> |
|---|---|
| Date | 2017-02-07 21:50 +0100 |
| Message-ID | <t8kS5-7Ey-1@gated-at.bofh.it> |
| In reply to | #1575460 |
On Tue, Feb 07, 2017 at 05:10:25PM +0900, Andi Shyti wrote:
> 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'.
>
I do not think it is possible.
if (IS_ERR(sdd->src_clk)) {
ret = PTR_ERR(sdd->src_clk);
goto err_deref_master;
}
> 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
It is a false positive.
Best regards,
Krzysztof
>
> 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
>
[toc] | [prev] | [next] | [standalone]
| From | Andi Shyti <andi.shyti@samsung.com> |
|---|---|
| Date | 2017-02-08 06:40 +0100 |
| Message-ID | <t8t90-4vJ-7@gated-at.bofh.it> |
| In reply to | #1576044 |
> > This patch fixes '1397922 Division or modulo by zero' from > > scan.coverity.com > > It is a false positive. Yes... sorry for these two spam/patches... they are just fast after holiday "fixes"... please ignore them. Andi
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web