From 2fd219108ef3cf22a79c49f56c53fc5a3ff5b06e Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Fri, 16 Jan 2009 09:23:25 -0500 Subject: em28xx: Fix audio URB transfer buffer race condition MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Robert Krakora em28xx: Fix audio URB transfer buffer memory leak and race condition/corruption of capture pointer Leak fix kindly contributed by Pádraig Brady. Priority: normal Signed-off-by: Robert Krakora Signed-off-by: Mauro Carvalho Chehab --- linux/drivers/media/video/em28xx/em28xx-audio.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'linux/drivers/media/video/em28xx/em28xx-audio.c') diff --git a/linux/drivers/media/video/em28xx/em28xx-audio.c b/linux/drivers/media/video/em28xx/em28xx-audio.c index 34c494d68..0d6a3a9ec 100644 --- a/linux/drivers/media/video/em28xx/em28xx-audio.c +++ b/linux/drivers/media/video/em28xx/em28xx-audio.c @@ -66,6 +66,9 @@ static int em28xx_isoc_audio_deinit(struct em28xx *dev) usb_unlink_urb(dev->adev.urb[i]); usb_free_urb(dev->adev.urb[i]); dev->adev.urb[i] = NULL; + + kfree(dev->adev.transfer_buffer[i]); + dev->adev.transfer_buffer[i] = NULL; } return 0; @@ -458,11 +461,15 @@ static snd_pcm_uframes_t snd_em28xx_capture_pointer(struct snd_pcm_substream *substream) #endif { - struct em28xx *dev; + unsigned long flags; + struct em28xx *dev; snd_pcm_uframes_t hwptr_done; + dev = snd_pcm_substream_chip(substream); + spin_lock_irqsave(&dev->adev.slock, flags); hwptr_done = dev->adev.hwptr_done_capture; + spin_unlock_irqrestore(&dev->adev.slock, flags); return hwptr_done; } -- cgit v1.2.3