All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ASoC: stm32: sai: Fix unsigned comparison with less than zero
@ 2018-11-29  2:06 Wen Yang
  2018-11-29 11:55 ` Mark Brown
  0 siblings, 1 reply; 2+ messages in thread
From: Wen Yang @ 2018-11-29  2:06 UTC (permalink / raw)
  To: olivier.moysan, arnaud.pouliquen, broonie, tiwai, mcoquelin.stm32
  Cc: linux-kernel, zhong.weidong, Wen Yang, Liam Girdwood,
	Jaroslav Kysela, Alexandre Torgue, Julia Lawall, Wen Yang,
	linux-stm32

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


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] ASoC: stm32: sai: Fix unsigned comparison with less than zero
  2018-11-29  2:06 [PATCH] ASoC: stm32: sai: Fix unsigned comparison with less than zero Wen Yang
@ 2018-11-29 11:55 ` Mark Brown
  0 siblings, 0 replies; 2+ messages in thread
From: Mark Brown @ 2018-11-29 11:55 UTC (permalink / raw)
  To: Wen Yang
  Cc: olivier.moysan, arnaud.pouliquen, tiwai, mcoquelin.stm32,
	linux-kernel, zhong.weidong, Liam Girdwood, Jaroslav Kysela,
	Alexandre Torgue, Julia Lawall, Wen Yang, linux-stm32

[-- Attachment #1: Type: text/plain, Size: 339 bytes --]

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.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-11-29 11:56 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-29  2:06 [PATCH] ASoC: stm32: sai: Fix unsigned comparison with less than zero Wen Yang
2018-11-29 11:55 ` Mark Brown

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.