ALSA: pcm: fix infinite loop in snd_pcm_update_hw_ptr0()
When period interrupts are disabled, snd_pcm_update_hw_ptr0() compares
the current time against the time estimated for the current hardware
pointer to detect xruns. The somewhat fuzzy threshold in the while loop
makes it possible that hdelta becomes negative; the comparison being
done with unsigned types then makes the loop go through the entire 263
negative range, and, depending on the value, never reach an unsigned
value that is small enough to stop the loop. Doing this with interrupts
disabled results in the machine locking up.
To prevent this, ensure that the loop condition uses signed types for
both operands so that the comparison is correctly done.
Many thanks to Kelly Anderson for debugging this.
Reported-by: Nix <email@example.com>
Reported-by: "Christopher K." <firstname.lastname@example.org>
Reported-and-tested-by: Kelly Anderson <email@example.com>
Signed-off-by: Kelly Anderson <firstname.lastname@example.org>
[cl: remove unneeded casts; use a temp variable]
Signed-off-by: Clemens Ladisch <email@example.com>
Cc: 2.6.38 <firstname.lastname@example.org>