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

Free allocated memory

Signed-off-by: Douglas Schilling Landgraf <dougsland@linuxtv.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>

authored by Douglas Schilling Landgraf and committed by Mauro Carvalho Chehab 4faf1004 7935eeae

+14 -5
+14 -5
drivers/media/dvb/dvb-usb/usb-urb.c
··· 135 136 static int usb_bulk_urb_init(struct usb_data_stream *stream) 137 { 138 - int i; 139 140 if ((i = usb_allocate_stream_buffers(stream,stream->props.count, 141 stream->props.u.bulk.buffersize)) < 0) ··· 143 144 /* allocate the URBs */ 145 for (i = 0; i < stream->props.count; i++) { 146 - if ((stream->urb_list[i] = usb_alloc_urb(0,GFP_ATOMIC)) == NULL) 147 return -ENOMEM; 148 - 149 usb_fill_bulk_urb( stream->urb_list[i], stream->udev, 150 usb_rcvbulkpipe(stream->udev,stream->props.endpoint), 151 stream->buf_list[i], ··· 174 for (i = 0; i < stream->props.count; i++) { 175 struct urb *urb; 176 int frame_offset = 0; 177 - if ((stream->urb_list[i] = 178 - usb_alloc_urb(stream->props.u.isoc.framesperurb,GFP_ATOMIC)) == NULL) 179 return -ENOMEM; 180 181 urb = stream->urb_list[i]; 182
··· 135 136 static int usb_bulk_urb_init(struct usb_data_stream *stream) 137 { 138 + int i, j; 139 140 if ((i = usb_allocate_stream_buffers(stream,stream->props.count, 141 stream->props.u.bulk.buffersize)) < 0) ··· 143 144 /* allocate the URBs */ 145 for (i = 0; i < stream->props.count; i++) { 146 + stream->urb_list[i] = usb_alloc_urb(0, GFP_ATOMIC); 147 + if (!stream->urb_list[i]) { 148 + deb_mem("not enough memory for urb_alloc_urb!.\n"); 149 + for (j = 0; j < i; j++) 150 + usb_free_urb(stream->urb_list[i]); 151 return -ENOMEM; 152 + } 153 usb_fill_bulk_urb( stream->urb_list[i], stream->udev, 154 usb_rcvbulkpipe(stream->udev,stream->props.endpoint), 155 stream->buf_list[i], ··· 170 for (i = 0; i < stream->props.count; i++) { 171 struct urb *urb; 172 int frame_offset = 0; 173 + 174 + stream->urb_list[i] = usb_alloc_urb(stream->props.u.isoc.framesperurb, GFP_ATOMIC); 175 + if (!stream->urb_list[i]) { 176 + deb_mem("not enough memory for urb_alloc_urb!\n"); 177 + for (j = 0; j < i; j++) 178 + usb_free_urb(stream->urb_list[i]); 179 return -ENOMEM; 180 + } 181 182 urb = stream->urb_list[i]; 183