2018-11-29 02:09:35

by Wen Yang

[permalink] [raw]
Subject: [PATCH] ASoC: stm32: sai: Fix unsigned comparison with less than zero

The return from the call to stm32_sai_get_clk_div can be a negative error
code however this is being assigned to an unsigned variable 'div'
hence the check is always false. Fix this by making 'div' an
int.

Detected by Coccinelle ("Unsigned expression compared with zero:stages
< 0")

Signed-off-by: Wen Yang <[email protected]>
CC: Mark Brown <[email protected]>
CC: Olivier Moysan <[email protected]>
CC: Arnaud Pouliquen <[email protected]>
CC: Liam Girdwood <[email protected]>
CC: Jaroslav Kysela <[email protected]>
CC: Takashi Iwai <[email protected]>
CC: Maxime Coquelin <[email protected]>
CC: Alexandre Torgue <[email protected]>
CC: Julia Lawall <[email protected]>
CC: Wen Yang <[email protected]>
CC: [email protected]
CC: [email protected]
---
sound/soc/stm/stm32_sai_sub.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sound/soc/stm/stm32_sai_sub.c b/sound/soc/stm/stm32_sai_sub.c
index 211589b0b2ef..6e9fff0f9ed7 100644
--- a/sound/soc/stm/stm32_sai_sub.c
+++ b/sound/soc/stm/stm32_sai_sub.c
@@ -336,7 +336,7 @@ static int stm32_sai_mclk_set_rate(struct clk_hw *hw, unsigned long rate,
{
struct stm32_sai_mclk_data *mclk = to_mclk_data(hw);
struct stm32_sai_sub_data *sai = mclk->sai_data;
- unsigned int div;
+ int div;
int ret;

div = stm32_sai_get_clk_div(sai, parent_rate, rate);
--
2.19.1



2018-11-29 11:57:42

by Mark Brown

[permalink] [raw]
Subject: Re: [PATCH] ASoC: stm32: sai: Fix unsigned comparison with less than zero

On Thu, Nov 29, 2018 at 10:06:11AM +0800, Wen Yang wrote:
> The return from the call to stm32_sai_get_clk_div can be a negative error
> code however this is being assigned to an unsigned variable 'div'
> hence the check is always false. Fix this by making 'div' an
> int.

This doesn't apply against current code, please check and resend.


Attachments:
(No filename) (346.00 B)
signature.asc (499.00 B)
Download all attachments