diff options
author | Douglas Schilling Landgraf <dougsland@linuxtv.org> | 2008-11-12 00:56:56 -0200 |
---|---|---|
committer | Douglas Schilling Landgraf <dougsland@linuxtv.org> | 2008-11-12 00:56:56 -0200 |
commit | 9690379dc06a080d7172bc3b2d21544f2bf3d8e1 (patch) | |
tree | 01c5a477e2430ca33a972f0b04b3dd7e1cff879f | |
parent | cc6988d1d04471ba46cd740cca95c3fddfefc7bf (diff) | |
download | mediapointer-dvb-s2-9690379dc06a080d7172bc3b2d21544f2bf3d8e1.tar.gz mediapointer-dvb-s2-9690379dc06a080d7172bc3b2d21544f2bf3d8e1.tar.bz2 |
usb-urb: fix memory leak
From: Douglas Schilling Landgraf <dougsland@linuxtv.org>
Free allocated memory
Priority: high
Signed-off-by: Douglas Schilling Landgraf <dougsland@linuxtv.org>
-rw-r--r-- | linux/drivers/media/dvb/dvb-usb/usb-urb.c | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/linux/drivers/media/dvb/dvb-usb/usb-urb.c b/linux/drivers/media/dvb/dvb-usb/usb-urb.c index 5caec2034..eb3aaaf7a 100644 --- a/linux/drivers/media/dvb/dvb-usb/usb-urb.c +++ b/linux/drivers/media/dvb/dvb-usb/usb-urb.c @@ -139,7 +139,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) { - int i; + int i, j; if ((i = usb_allocate_stream_buffers(stream,stream->props.count, stream->props.u.bulk.buffersize)) < 0) @@ -147,9 +147,13 @@ static int usb_bulk_urb_init(struct usb_data_stream *stream) /* allocate the URBs */ 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; - + } usb_fill_bulk_urb( stream->urb_list[i], stream->udev, usb_rcvbulkpipe(stream->udev,stream->props.endpoint), stream->buf_list[i], @@ -174,9 +178,14 @@ static int usb_isoc_urb_init(struct usb_data_stream *stream) for (i = 0; i < stream->props.count; i++) { struct urb *urb; 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; + } urb = stream->urb_list[i]; |