All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/4] em28xx: Fix audio URB transfer buffer memory leak and race condition/corruption of capture pointer
  2009-01-14 18:44   ` Robert Krakora
@ 2009-01-14 18:55     ` Robert Krakora
  2009-01-14 20:02       ` Fwd: " Robert Krakora
  0 siblings, 1 reply; 7+ messages in thread
From: Robert Krakora @ 2009-01-14 18:55 UTC (permalink / raw)
  To: video4linux-list

em28xx: Fix audio URB transfer buffer memory leak and race
condition/corruption of capture pointer

From: Robert Krakora <rob.krakora@messagenetsystems.com>

Fix audio URB transfer buffer memory leak and race
condition/corruption of capture pointer

Priority: normal

Signed-off-by: Robert Krakora <rob.krakora@messagenetsystems.com>

diff -r 6896782d783d linux/drivers/media/video/em28xx/em28xx-audio.c
--- a/linux/drivers/media/video/em28xx/em28xx-audio.c   Wed Jan 14
10:06:12 2009 -0200
+++ b/linux/drivers/media/video/em28xx/em28xx-audio.c   Wed Jan 14
12:47:00 2009 -0500
@@ -62,11 +62,20 @@
     int i;

     dprintk("Stopping isoc\n");
-       for (i = 0; i < EM28XX_AUDIO_BUFS; i++) {
-               usb_unlink_urb(dev->adev.urb[i]);
-               usb_free_urb(dev->adev.urb[i]);
-               dev->adev.urb[i] = NULL;
-       }
+        for (i = 0; i < EM28XX_AUDIO_BUFS; i++) {
+               usb_unlink_urb(dev->adev.urb[i]);
+               usb_free_urb(dev->adev.urb[i]);
+               dev->adev.urb[i] = NULL;
+               if (dev->adev.urb[i]) {
+                       usb_unlink_urb(dev->adev.urb[i]);
+                       usb_free_urb(dev->adev.urb[i]);
+                       dev->adev.urb[i] = NULL;
+               }
+                if (dev->adev.transfer_buffer) {
+                       kfree(dev->adev.transfer_buffer[i]);
+                       dev->adev.transfer_buffer[i] = NULL;
+               }
+        }

     return 0;
 }
@@ -458,11 +467,15 @@
                                                 *substream)
 #endif
 {
+       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;
 }

--
video4linux-list mailing list
Unsubscribe mailto:video4linux-list-request@redhat.com?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/video4linux-list

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 1/4] em28xx: Fix audio URB transfer buffer memory leak and race condition/corruption of capture pointer
  2009-01-14 20:02       ` Fwd: " Robert Krakora
@ 2009-01-14 20:08         ` Robert Krakora
  2009-01-15 22:31         ` Robert Krakora
  1 sibling, 0 replies; 7+ messages in thread
From: Robert Krakora @ 2009-01-14 20:08 UTC (permalink / raw)
  To: video4linux-list

em28xx: Fix audio URB transfer buffer memory leak and race
condition/corruption of capture pointer

From: Robert Krakora <rob.krakora@messagenetsystems.com>

Fix audio URB transfer buffer memory leak and race
condition/corruption of capture pointer

Priority: normal

Signed-off-by: Robert Krakora <rob.krakora@messagenetsystems.com>

diff -r 6896782d783d linux/drivers/media/video/em28xx/em28xx-audio.c
--- a/linux/drivers/media/video/em28xx/em28xx-audio.c   Wed Jan 14
10:06:12 2009 -0200
+++ b/linux/drivers/media/video/em28xx/em28xx-audio.c   Wed Jan 14
15:01:20 2009 -0500
@@ -62,11 +62,17 @@
       int i;

       dprintk("Stopping isoc\n");
-       for (i = 0; i < EM28XX_AUDIO_BUFS; i++) {
-               usb_unlink_urb(dev->adev.urb[i]);
-               usb_free_urb(dev->adev.urb[i]);
-               dev->adev.urb[i] = NULL;
-       }
+        for (i = 0; i < EM28XX_AUDIO_BUFS; i++) {
+               if (dev->adev.urb[i]) {
+                       usb_unlink_urb(dev->adev.urb[i]);
+                       usb_free_urb(dev->adev.urb[i]);
+                       dev->adev.urb[i] = NULL;
+               }
+                if (dev->adev.transfer_buffer[i]) {
+                       kfree(dev->adev.transfer_buffer[i]);
+                       dev->adev.transfer_buffer[i] = NULL;
+               }
+        }

       return 0;
 }
@@ -458,11 +464,15 @@
                                                   *substream)
 #endif
 {
+       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;
 }

--
video4linux-list mailing list
Unsubscribe mailto:video4linux-list-request@redhat.com?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/video4linux-list

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 1/4] em28xx: Fix audio URB transfer buffer memory leak and race condition/corruption of capture pointer
@ 2009-01-15 14:37 Robert Krakora
  2009-01-15 17:11 ` Robert Krakora
  0 siblings, 1 reply; 7+ messages in thread
From: Robert Krakora @ 2009-01-15 14:37 UTC (permalink / raw)
  To: video4linux-list, Pádraig Brady

em28xx: Fix audio URB transfer buffer memory leak and race
condition/corruption of capture pointer

From: Robert Krakora <rob.krakora@messagenetsystems.com>

Fix audio URB transfer buffer memory leak and race
condition/corruption of capture pointer

Priority: normal

Signed-off-by: Robert Krakora <rob.krakora@messagenetsystems.com>

diff -r 6896782d783d linux/drivers/media/video/em28xx/em28xx-audio.c
--- a/linux/drivers/media/video/em28xx/em28xx-audio.c   Wed Jan 14
10:06:12 2009 -0200
+++ b/linux/drivers/media/video/em28xx/em28xx-audio.c   Wed Jan 14
12:47:00 2009 -0500
@@ -62,11 +62,20 @@
       int i;

       dprintk("Stopping isoc\n");
-       for (i = 0; i < EM28XX_AUDIO_BUFS; i++) {
-               usb_unlink_urb(dev->adev.urb[i]);
-               usb_free_urb(dev->adev.urb[i]);
-               dev->adev.urb[i] = NULL;
-       }
+        for (i = 0; i < EM28XX_AUDIO_BUFS; i++) {
+               if (dev->adev.urb[i]) {
+                       usb_unlink_urb(dev->adev.urb[i]);
+                       usb_free_urb(dev->adev.urb[i]);
+                       dev->adev.urb[i] = NULL;
+               }
+                if (dev->adev.transfer_buffer[i]) {
+                       kfree(dev->adev.transfer_buffer[i]);
+                       dev->adev.transfer_buffer[i] = NULL;
+               }
+        }

       return 0;
 }
@@ -458,11 +467,15 @@
                                                   *substream)
 #endif
 {
+       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;
 }

--
video4linux-list mailing list
Unsubscribe mailto:video4linux-list-request@redhat.com?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/video4linux-list

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 1/4] em28xx: Fix audio URB transfer buffer memory leak and race condition/corruption of capture pointer
  2009-01-15 14:37 [PATCH 1/4] em28xx: Fix audio URB transfer buffer memory leak and race condition/corruption of capture pointer Robert Krakora
@ 2009-01-15 17:11 ` Robert Krakora
  2009-01-16  1:59   ` CityK
  0 siblings, 1 reply; 7+ messages in thread
From: Robert Krakora @ 2009-01-15 17:11 UTC (permalink / raw)
  To: video4linux-list

em28xx: Fix audio URB transfer buffer memory leak and race
condition/corruption of capture pointer

From: Robert Krakora <rob.krakora@messagenetsystems.com>

Fix audio URB transfer buffer memory leak and race
condition/corruption of capture pointer

Padraig found this leak previously so his fix is utilized in this
patch instead of mine.  Many thanks to him for aiding this "newbie".

Priority: normal

Signed-off-by: Robert Krakora <rob.krakora@messagenetsystems.com>

diff -r 6896782d783d linux/drivers/media/video/em28xx/em28xx-audio.c
--- a/linux/drivers/media/video/em28xx/em28xx-audio.c   Wed Jan 14
10:06:12 2009 -0200
+++ b/linux/drivers/media/video/em28xx/em28xx-audio.c   Wed Jan 14
12:47:00 2009 -0500
@@ -62,11 +62,20 @@
      int i;

      dprintk("Stopping isoc\n");
-       for (i = 0; i < EM28XX_AUDIO_BUFS; i++) {
-               usb_unlink_urb(dev->adev.urb[i]);
-               usb_free_urb(dev->adev.urb[i]);
-               dev->adev.urb[i] = NULL;
-       }
+        for (i = 0; i < EM28XX_AUDIO_BUFS; i++) {
+               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 +467,15 @@
                                                  *substream)
 #endif
 {
+       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;
 }



-- 
Rob Krakora
Software Engineer
MessageNet Systems
101 East Carmel Dr. Suite 105
Carmel, IN 46032
(317)566-1677 Ext. 206
(317)663-0808 Fax

--
video4linux-list mailing list
Unsubscribe mailto:video4linux-list-request@redhat.com?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/video4linux-list

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 1/4] em28xx: Fix audio URB transfer buffer memory leak and race condition/corruption of capture pointer
  2009-01-14 20:02       ` Fwd: " Robert Krakora
  2009-01-14 20:08         ` Robert Krakora
@ 2009-01-15 22:31         ` Robert Krakora
  2009-01-16 14:23           ` Robert Krakora
  1 sibling, 1 reply; 7+ messages in thread
From: Robert Krakora @ 2009-01-15 22:31 UTC (permalink / raw)
  To: video4linux-list, Pádraig Brady

em28xx: Fix audio URB transfer buffer memory leak and race
condition/corruption of capture pointer

From: Robert Krakora <rob.krakora@messagenetsystems.com>

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 <rob.krakora@messagenetsystems.com>

diff -r 7981bdd4e25a linux/drivers/media/video/em28xx/em28xx-audio.c
--- a/linux/drivers/media/video/em28xx/em28xx-audio.c   Mon Jan 12
00:18:04 2009 +0000
+++ b/linux/drivers/media/video/em28xx/em28xx-audio.c   Thu Jan 15
17:27:27 2009 -0500
@@ -66,6 +66,9 @@
                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 @@
                                                    *substream)
 #endif
 {
+       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;
 }

--
video4linux-list mailing list
Unsubscribe mailto:video4linux-list-request@redhat.com?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/video4linux-list

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/4] em28xx: Fix audio URB transfer buffer memory leak and race condition/corruption of capture pointer
  2009-01-15 17:11 ` Robert Krakora
@ 2009-01-16  1:59   ` CityK
  0 siblings, 0 replies; 7+ messages in thread
From: CityK @ 2009-01-16  1:59 UTC (permalink / raw)
  To: Robert Krakora; +Cc: video4linux-list, Linux-media

Hi Robert,

I don't know if you're aware, but we've recently switched mailing lists
for which patches should be submitted (see Mauro's note:
http://www.linuxtv.org/news.php?entry=2009-01-06.mchehab) ... I've been
busy trying to update the likes of articles such as 
http://www.linuxtv.org/wiki/index.php/Development:_How_to_submit_patches 
that may have still contained instructions/links to the older mailing
lists.  Sorry for the inconvenience.  Unless Mauro, or a driver
maintainer has already picked them up, please resend them to the new list.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 1/4] em28xx: Fix audio URB transfer buffer memory leak and race condition/corruption of capture pointer
  2009-01-15 22:31         ` Robert Krakora
@ 2009-01-16 14:23           ` Robert Krakora
  0 siblings, 0 replies; 7+ messages in thread
From: Robert Krakora @ 2009-01-16 14:23 UTC (permalink / raw)
  To: linux-media

em28xx: Fix audio URB transfer buffer memory leak and race
condition/corruption of capture pointer

From: Robert Krakora <rob.krakora@messagenetsystems.com>

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 <rob.krakora@messagenetsystems.com>

diff -r 7981bdd4e25a linux/drivers/media/video/em28xx/em28xx-audio.c
--- a/linux/drivers/media/video/em28xx/em28xx-audio.c   Mon Jan 12
00:18:04 2009 +0000
+++ b/linux/drivers/media/video/em28xx/em28xx-audio.c   Thu Jan 15
17:27:27 2009 -0500
@@ -66,6 +66,9 @@
               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 @@
                                                   *substream)
 #endif
 {
+       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;
 }

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2009-01-16 14:23 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-01-15 14:37 [PATCH 1/4] em28xx: Fix audio URB transfer buffer memory leak and race condition/corruption of capture pointer Robert Krakora
2009-01-15 17:11 ` Robert Krakora
2009-01-16  1:59   ` CityK
  -- strict thread matches above, loose matches on Subject: below --
2009-01-14 18:04 [PATCH 2.6.27.8 1/1] " Robert Krakora
2009-01-14 18:31 ` Robert Krakora
2009-01-14 18:44   ` Robert Krakora
2009-01-14 18:55     ` [PATCH 1/4] " Robert Krakora
2009-01-14 20:02       ` Fwd: " Robert Krakora
2009-01-14 20:08         ` Robert Krakora
2009-01-15 22:31         ` Robert Krakora
2009-01-16 14:23           ` Robert Krakora

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.