All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Pádraig Brady" <P@draigBrady.com>
To: Robert Krakora <rob.krakora@messagenetsystems.com>
Cc: video4linux-list@redhat.com
Subject: Re: [PATCH 2.6.27.8 1/1] em28xx: Fix audio URB transfer buffer memory leak and race condition/corruption of capture pointer
Date: Thu, 15 Jan 2009 14:58:35 +0000	[thread overview]
Message-ID: <496F4F1B.1050706@draigBrady.com> (raw)
In-Reply-To: <b24e53350901150632u2f031fcm3c6f34b6b0e81100@mail.gmail.com>

Robert Krakora wrote:
> On Thu, Jan 15, 2009 at 6:06 AM, Pádraig Brady <P@draigbrady.com> wrote:
>> Robert Krakora wrote:
>>> em28xx: Fix audio URB transfer buffer memory leak and race
>>> condition/corruption of capture pointer
>>>
>>>
>>> Signed-off-by: Robert V. 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;
>>>  }
>> That looks a bit incorrect. I fixed this last week in Markus'
>> repository, as I thought the leak was specific to that tree:
>> http://mcentral.de/hg/~mrec/em28xx-new/diff/1cfd9010a552/em28xx-audio.c
>>
> 
> I fail to see what looks incorrect about testing for NULL pointers
> before freeing.

That's redundant/inefficient. kfree(NULL) is fine.

> I did have a bug where I left the index number off of
> the transfer buffer array which Devin kindly pointed out yesterday.

I was referring to that yes.

I was also referring to the fact you have 2 calls to free the URBs.

I suggest you just do what I did in my patch.
I've tested it well. Without it I was leaking 48KiB
every time VLC changed channel.

cheers,
Pádraig.

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

  reply	other threads:[~2009-01-15 15:15 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-01-14 18:04 [PATCH 2.6.27.8 1/1] em28xx: Fix audio URB transfer buffer memory leak and race condition/corruption of capture pointer 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
2009-01-15 11:06 ` [PATCH 2.6.27.8 1/1] " Pádraig Brady
2009-01-15 11:27   ` Markus Rechberger
2009-01-15 14:49     ` Robert Krakora
2009-01-15 14:32   ` Robert Krakora
2009-01-15 14:58     ` Pádraig Brady [this message]
2009-01-15 15:32       ` Robert Krakora

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=496F4F1B.1050706@draigBrady.com \
    --to=p@draigbrady.com \
    --cc=rob.krakora@messagenetsystems.com \
    --cc=video4linux-list@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.