From: Roel Kluin <12o3l@tiscali.nl> Date: Fri, 18 Apr 2008 10:25:41 +0000 (+0200) Subject: OSS: dmabuf: fix negative DMAbuf_get_buffer_pointer() check X-Git-Tag: v2.6.26-rc1~1087^2~28 X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0d52cea487c0213d6d7bca9c951210081e7b653b;p=linux-2.6 OSS: dmabuf: fix negative DMAbuf_get_buffer_pointer() check 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 --- diff --git a/sound/oss/dmabuf.c b/sound/oss/dmabuf.c index eaf69971bf..1e90d769b6 100644 --- a/sound/oss/dmabuf.c +++ b/sound/oss/dmabuf.c @@ -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