Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1672765 > unrolled thread

[PATCH][spi-next] spi: stm32: fix range limit checks on div

Started byColin King <colin.king@canonical.com>
First post2017-06-22 17:50 +0200
Last post2017-06-23 14:50 +0200
Articles 5 — 4 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH][spi-next] spi: stm32: fix range limit checks on div Colin King <colin.king@canonical.com> - 2017-06-22 17:50 +0200
    Re: [PATCH][spi-next] spi: stm32: fix range limit checks on div Amelie DELAUNAY <amelie.delaunay@st.com> - 2017-06-22 18:00 +0200
      Re: [PATCH][spi-next] spi: stm32: fix range limit checks on div Colin Ian King <colin.king@canonical.com> - 2017-06-22 18:00 +0200
      Re: [PATCH][spi-next] spi: stm32: fix range limit checks on div Mark Brown <broonie@kernel.org> - 2017-06-23 13:20 +0200
    Re: [PATCH][spi-next] spi: stm32: fix range limit checks on div Amelie DELAUNAY <amelie.delaunay@st.com> - 2017-06-23 14:50 +0200

#1672765 — [PATCH][spi-next] spi: stm32: fix range limit checks on div

FromColin King <colin.king@canonical.com>
Date2017-06-22 17:50 +0200
Subject[PATCH][spi-next] spi: stm32: fix range limit checks on div
Message-ID<tVcwO-6Is-17@gated-at.bofh.it>
From: Colin Ian King <colin.king@canonical.com>

Currently the check for range limits on div is incorrect and will
never return -EINVAL. Fix this by replacing && with ||

Detected by CoverityScan, CID#1446580 ("Structurally dead code")

Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 drivers/spi/spi-stm32.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/spi/spi-stm32.c b/drivers/spi/spi-stm32.c
index 0553f61ab3b7..b75909e7b117 100644
--- a/drivers/spi/spi-stm32.c
+++ b/drivers/spi/spi-stm32.c
@@ -262,7 +262,7 @@ static int stm32_spi_prepare_mbr(struct stm32_spi *spi, u32 speed_hz)
 	 * no need to check it there.
 	 * However, we need to ensure the following calculations.
 	 */
-	if ((div < SPI_MBR_DIV_MIN) &&
+	if ((div < SPI_MBR_DIV_MIN) ||
 	    (div > SPI_MBR_DIV_MAX))
 		return -EINVAL;
 
-- 
2.11.0

[toc] | [next] | [standalone]


#1672776

FromAmelie DELAUNAY <amelie.delaunay@st.com>
Date2017-06-22 18:00 +0200
Message-ID<tVcGu-6LO-35@gated-at.bofh.it>
In reply to#1672765
Hi Colin,

I'm preparing a v2 for the initial patchset introducing spi-stm32, if 
you agree, I can directly add your fix.

Regards,
Amelie

On 06/22/2017 05:41 PM, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
> 
> Currently the check for range limits on div is incorrect and will
> never return -EINVAL. Fix this by replacing && with ||
> 
> Detected by CoverityScan, CID#1446580 ("Structurally dead code")
> 
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>   drivers/spi/spi-stm32.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/spi/spi-stm32.c b/drivers/spi/spi-stm32.c
> index 0553f61ab3b7..b75909e7b117 100644
> --- a/drivers/spi/spi-stm32.c
> +++ b/drivers/spi/spi-stm32.c
> @@ -262,7 +262,7 @@ static int stm32_spi_prepare_mbr(struct stm32_spi *spi, u32 speed_hz)
>   	 * no need to check it there.
>   	 * However, we need to ensure the following calculations.
>   	 */
> -	if ((div < SPI_MBR_DIV_MIN) &&
> +	if ((div < SPI_MBR_DIV_MIN) ||
>   	    (div > SPI_MBR_DIV_MAX))
>   		return -EINVAL;
>   
> 

[toc] | [prev] | [next] | [standalone]


#1672777

FromColin Ian King <colin.king@canonical.com>
Date2017-06-22 18:00 +0200
Message-ID<tVcGv-6LO-41@gated-at.bofh.it>
In reply to#1672776
On 22/06/17 16:49, Amelie DELAUNAY wrote:
> Hi Colin,
> 
> I'm preparing a v2 for the initial patchset introducing spi-stm32, if
> you agree, I can directly add your fix.

Yep, please do, sounds like a plan.

Colin
> 
> Regards,
> Amelie
> 
> On 06/22/2017 05:41 PM, Colin King wrote:
>> From: Colin Ian King <colin.king@canonical.com>
>>
>> Currently the check for range limits on div is incorrect and will
>> never return -EINVAL. Fix this by replacing && with ||
>>
>> Detected by CoverityScan, CID#1446580 ("Structurally dead code")
>>
>> Signed-off-by: Colin Ian King <colin.king@canonical.com>
>> ---
>>   drivers/spi/spi-stm32.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/spi/spi-stm32.c b/drivers/spi/spi-stm32.c
>> index 0553f61ab3b7..b75909e7b117 100644
>> --- a/drivers/spi/spi-stm32.c
>> +++ b/drivers/spi/spi-stm32.c
>> @@ -262,7 +262,7 @@ static int stm32_spi_prepare_mbr(struct stm32_spi
>> *spi, u32 speed_hz)
>>        * no need to check it there.
>>        * However, we need to ensure the following calculations.
>>        */
>> -    if ((div < SPI_MBR_DIV_MIN) &&
>> +    if ((div < SPI_MBR_DIV_MIN) ||
>>           (div > SPI_MBR_DIV_MAX))
>>           return -EINVAL;
>>  

[toc] | [prev] | [next] | [standalone]


#1673479

FromMark Brown <broonie@kernel.org>
Date2017-06-23 13:20 +0200
Message-ID<tVuN3-1sx-5@gated-at.bofh.it>
In reply to#1672776

[Multipart message — attachments visible in raw view] — view raw

On Thu, Jun 22, 2017 at 05:49:10PM +0200, Amelie DELAUNAY wrote:

> I'm preparing a v2 for the initial patchset introducing spi-stm32, if you
> agree, I can directly add your fix.

Please don't resubmit patches that have already been applied, you should
submit patches against current code in the tree you're expecting things
to be applied to.  If any updates are needed to a patch that's already
been applied you should submit incremental patches which make those
updates.  This avoids having to change published git commits which could
cause problems for people working against git.

Please don't top post, reply in line with needed context.  This allows
readers to readily follow the flow of conversation and understand what
you are talking about and also helps ensure that everything in the
discussion is being addressed.

[toc] | [prev] | [next] | [standalone]


#1673517

FromAmelie DELAUNAY <amelie.delaunay@st.com>
Date2017-06-23 14:50 +0200
Message-ID<tVwca-2bn-3@gated-at.bofh.it>
In reply to#1672765
On 06/22/2017 05:41 PM, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
> 
> Currently the check for range limits on div is incorrect and will
> never return -EINVAL. Fix this by replacing && with ||
> 
> Detected by CoverityScan, CID#1446580 ("Structurally dead code")
> 
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>   drivers/spi/spi-stm32.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/spi/spi-stm32.c b/drivers/spi/spi-stm32.c
> index 0553f61ab3b7..b75909e7b117 100644
> --- a/drivers/spi/spi-stm32.c
> +++ b/drivers/spi/spi-stm32.c
> @@ -262,7 +262,7 @@ static int stm32_spi_prepare_mbr(struct stm32_spi *spi, u32 speed_hz)
>   	 * no need to check it there.
>   	 * However, we need to ensure the following calculations.
>   	 */
> -	if ((div < SPI_MBR_DIV_MIN) &&
> +	if ((div < SPI_MBR_DIV_MIN) ||
>   	    (div > SPI_MBR_DIV_MAX))
>   		return -EINVAL;
>   
> 

Reviewed-by: Amelie Delaunay <amelie.delaunay@st.com>

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web