Skip to contentSkip to conversation

OSS: dmabuf: fix negative DMAbuf_get_buffer_pointer() check

PATCH Applied Roel Kluin 2 participants 2 messages Apr 17, 2008 – Apr 18, 2008 Sound

lore
Share & tools
lore

Roel Kluin

author
#0 lore raw

PATCH 1/1 OSS: dmabuf: fix negative DMAbuf_get_buffer_pointer() check

Too late for OSS?
---
Since unsigned active_offs < 0 is even true when DMAbuf_get_buffer_pointer() returns negative

---

sound/oss/dmabuf.c +2 -2
index eaf6997..1e90d76 100644
@@ -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
Applied
#1 lore raw

At Thu, 17 Apr 2008 20:38:57 +0200,

Quoted 7 lines · Roel Kluin

Too late for OSS?
---
Since unsigned active_offs < 0 is even true when DMAbuf_get_buffer_pointer() returns negative

I applied it to my git tree. Thanks.

Takashi

Quoted 23 lines

---

sound/oss/dmabuf.c +2 -3
index eaf6997..1e90d76 100644
@@ -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
--

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/