[Linux-stm32] [PATCH] ASoC: stm32: sai: Fix unsigned comparison with less than zero

Wen Yang wen.yang99 at zte.com.cn
Thu Nov 29 02:06:11 UTC 2018


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 <wen.yang99 at zte.com.cn>
CC: Mark Brown <broonie at kernel.org>
CC: Olivier Moysan <olivier.moysan at st.com>
CC: Arnaud Pouliquen <arnaud.pouliquen at st.com>
CC: Liam Girdwood <lgirdwood at gmail.com>
CC: Jaroslav Kysela <perex at perex.cz>
CC: Takashi Iwai <tiwai at suse.com>
CC: Maxime Coquelin <mcoquelin.stm32 at gmail.com>
CC: Alexandre Torgue <alexandre.torgue at st.com>
CC: Julia Lawall <julia.lawall at lip6.fr>
CC: Wen Yang <yellowriver2010 at hotmail.com>
CC: linux-stm32 at st-md-mailman.stormreply.com
CC: linux-kernel at vger.kernel.org
---
 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




More information about the Linux-stm32 mailing list