mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 1/2] ALSA: firewire-tascam: Fix infinite loop in snd_tscm_stream_get_rate()
@ 2017-05-15  8:19 Geert Uytterhoeven
  2017-05-15  8:19 ` [PATCH 2/2] ALSA: firewire-tascam: Use do { } while for loops executed at least once Geert Uytterhoeven
  2017-05-15 14:07 ` [PATCH 1/2] ALSA: firewire-tascam: Fix infinite loop in snd_tscm_stream_get_rate() Takashi Sakamoto
  0 siblings, 2 replies; 5+ messages in thread
From: Geert Uytterhoeven @ 2017-05-15  8:19 UTC (permalink / raw)
  To: Clemens Ladisch, Jaroslav Kysela, Takashi Iwai, Takashi Sakamoto
  Cc: Arnd Bergmann, alsa-devel, linux-kernel, Geert Uytterhoeven

Obviously the intention was to put a limit on the maximum number of
operations.  However, for this to work, the check should be
"&& trials++ < 5", not "|| trials++ < 5".

Fixes: 35efa5c489de63a9 ("ALSA: firewire-tascam: add streaming functionality")
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
---
Compile-tested only.

Triggered by a false-positive warning from gcc-4.1.2:

    warning: ‘err’ may be used uninitialized in this function
---
 sound/firewire/tascam/tascam-stream.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sound/firewire/tascam/tascam-stream.c b/sound/firewire/tascam/tascam-stream.c
index f1657a4e0621ef49..e433b92ac6904db5 100644
--- a/sound/firewire/tascam/tascam-stream.c
+++ b/sound/firewire/tascam/tascam-stream.c
@@ -84,7 +84,7 @@ int snd_tscm_stream_get_rate(struct snd_tscm *tscm, unsigned int *rate)
 	unsigned int trials = 0;
 	int err;
 
-	while (data == 0x0 || trials++ < 5) {
+	while (data == 0x0 && trials++ < 5) {
 		err = get_clock(tscm, &data);
 		if (err < 0)
 			return err;
-- 
2.7.4

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

end of thread, other threads:[~2017-05-15 14:40 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-15  8:19 [PATCH 1/2] ALSA: firewire-tascam: Fix infinite loop in snd_tscm_stream_get_rate() Geert Uytterhoeven
2017-05-15  8:19 ` [PATCH 2/2] ALSA: firewire-tascam: Use do { } while for loops executed at least once Geert Uytterhoeven
2017-05-15 14:07 ` [PATCH 1/2] ALSA: firewire-tascam: Fix infinite loop in snd_tscm_stream_get_rate() Takashi Sakamoto
2017-05-15 14:22   ` Geert Uytterhoeven
2017-05-15 14:40     ` Takashi Sakamoto

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®