]> git.karo-electronics.de Git - karo-tx-linux.git/commit
ALSA: pcm: fix delta calculation at boundary wraparound
authorClemens Ladisch <clemens@ladisch.de>
Tue, 25 May 2010 07:01:46 +0000 (09:01 +0200)
committerGreg Kroah-Hartman <gregkh@suse.de>
Mon, 5 Jul 2010 18:21:59 +0000 (11:21 -0700)
commit945fb1b1535c71df6d3ac4c1a52149662515d854
tree5c8984533060a7ea78d5400e4ab7ac56d5824e0e
parentf3b041d63fd763862ff0acd2612135d0502f9402
ALSA: pcm: fix delta calculation at boundary wraparound

commit b406e6103baa3da85950f22d3d46d21a8da654c5 upstream.

In the cleanup of the hw_ptr update functions in 2.6.33, the calculation
of the delta value was changed to use the modulo operator to protect
against a negative difference due to the pointer wrapping around at the
boundary.

However, the ptr variables are unsigned, so a negative difference would
result in the two complement's value which has no relation to the actual
difference relative to the boundary; the result is typically some value
near LONG_MAX-boundary.  Furthermore, even if the modulo operation would
be done with signed types, the result of a negative dividend could be
negative.

The invalid delta value is then caught by the following checks, but this
means that the pointer update is ignored.

To fix this, use a range check as in the other pointer calculations.

Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
sound/core/pcm_lib.c