OSS: dmabuf: fix negative DMAbuf_get_buffer_pointer() check
authorRoel Kluin <12o3l@tiscali.nl>
Fri, 18 Apr 2008 10:25:41 +0000 (12:25 +0200)
committerTakashi Iwai <tiwai@suse.de>
Thu, 24 Apr 2008 10:00:39 +0000 (12:00 +0200)
Since unsigned active_offs < 0 is even true when DMAbuf_get_buffer_pointer()
returns negative

Signed-off-by: Roel Kluin <12o3l@tiscali.nl>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/oss/dmabuf.c

index eaf69971bf92d5d5b54306dd2109d37ee5bffd07..1e90d769b62e3ef63181f809a5ccd36e819d126b 100644 (file)
@@ -795,9 +795,9 @@ static int find_output_space(int dev, char **buf, int *size)
 #ifdef BE_CONSERVATIVE
        active_offs = dmap->byte_counter + dmap->qhead * dmap->fragment_size;
 #else
-       active_offs = DMAbuf_get_buffer_pointer(dev, dmap, DMODE_OUTPUT);
+       active_offs = max(DMAbuf_get_buffer_pointer(dev, dmap, DMODE_OUTPUT), 0);
        /* Check for pointer wrapping situation */
-       if (active_offs < 0 || active_offs >= dmap->bytes_in_use)
+       if (active_offs >= dmap->bytes_in_use)
                active_offs = 0;
        active_offs += dmap->byte_counter;
 #endif