Commit 4faf1004 authored by Douglas Schilling Landgraf's avatar Douglas Schilling Landgraf Committed by Mauro Carvalho Chehab

V4L/DVB (9605): usb-urb: fix memory leak

Free allocated memory
Signed-off-by: default avatarDouglas Schilling Landgraf <dougsland@linuxtv.org>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent 7935eeae
...@@ -135,7 +135,7 @@ stream->buf_list[stream->buf_num], (long long)stream->dma_addr[stream->buf_num]) ...@@ -135,7 +135,7 @@ stream->buf_list[stream->buf_num], (long long)stream->dma_addr[stream->buf_num])
static int usb_bulk_urb_init(struct usb_data_stream *stream) static int usb_bulk_urb_init(struct usb_data_stream *stream)
{ {
int i; int i, j;
if ((i = usb_allocate_stream_buffers(stream,stream->props.count, if ((i = usb_allocate_stream_buffers(stream,stream->props.count,
stream->props.u.bulk.buffersize)) < 0) stream->props.u.bulk.buffersize)) < 0)
...@@ -143,9 +143,13 @@ static int usb_bulk_urb_init(struct usb_data_stream *stream) ...@@ -143,9 +143,13 @@ static int usb_bulk_urb_init(struct usb_data_stream *stream)
/* allocate the URBs */ /* allocate the URBs */
for (i = 0; i < stream->props.count; i++) { for (i = 0; i < stream->props.count; i++) {
if ((stream->urb_list[i] = usb_alloc_urb(0,GFP_ATOMIC)) == NULL) stream->urb_list[i] = usb_alloc_urb(0, GFP_ATOMIC);
if (!stream->urb_list[i]) {
deb_mem("not enough memory for urb_alloc_urb!.\n");
for (j = 0; j < i; j++)
usb_free_urb(stream->urb_list[i]);
return -ENOMEM; return -ENOMEM;
}
usb_fill_bulk_urb( stream->urb_list[i], stream->udev, usb_fill_bulk_urb( stream->urb_list[i], stream->udev,
usb_rcvbulkpipe(stream->udev,stream->props.endpoint), usb_rcvbulkpipe(stream->udev,stream->props.endpoint),
stream->buf_list[i], stream->buf_list[i],
...@@ -170,9 +174,14 @@ static int usb_isoc_urb_init(struct usb_data_stream *stream) ...@@ -170,9 +174,14 @@ static int usb_isoc_urb_init(struct usb_data_stream *stream)
for (i = 0; i < stream->props.count; i++) { for (i = 0; i < stream->props.count; i++) {
struct urb *urb; struct urb *urb;
int frame_offset = 0; int frame_offset = 0;
if ((stream->urb_list[i] =
usb_alloc_urb(stream->props.u.isoc.framesperurb,GFP_ATOMIC)) == NULL) stream->urb_list[i] = usb_alloc_urb(stream->props.u.isoc.framesperurb, GFP_ATOMIC);
if (!stream->urb_list[i]) {
deb_mem("not enough memory for urb_alloc_urb!\n");
for (j = 0; j < i; j++)
usb_free_urb(stream->urb_list[i]);
return -ENOMEM; return -ENOMEM;
}
urb = stream->urb_list[i]; urb = stream->urb_list[i];
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment