V4L/DVB:uvcvideo:fix uvc_alloc_urb_buffers()
A message that is not in the archive (sent off-list or not yet received): [email protected]
Laurent Pinchart
Acked-byHi,
Quoted 7 lines · On Sunday 27 September 2009 10:30:34 [email protected] wrote:
From: Ming Lei <[email protected]>
This patch sets
stream->urb_sizeas psize*npackets before callinguvc_alloc_urb_buffers, which may fix a possible failure ofusb_buffer_freein caseusb_buffer_allocreturns NULL. The patch is based on the ideas below:
Quoted 8 lines
1,If
usb_buffer_alloccan't allocate a buffer sucessfully,uvc_free_urb_bufferswill be called to free the allocated buffers, andstream->urb_sizeis required to be passed tousb_buffer_free;2,uvc_free_urb_buffers can reset
stream->urb_size.This patch is against linux-v2.6.31-next-20090926.
Good catch, thanks.
Quoted 1 line
Signed-off-by Ming Lei <[email protected]>
Acked-by Laurent Pinchart <[email protected]>
I've applied the patch to my tree and I'll send a pull request.
Quoted 30 lines
--- drivers/media/video/uvc/uvc_video.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)(quoted diff) +0
-0b/drivers/media/video/uvc/uvc_video.c index f960e8e..31dba66 100644drivers/media/video/uvc/uvc_video.c +2
-1@@ -768,9 +768,10 @@ static int uvc_alloc_urb_buffers(struct uvc_streaming *stream,/* Retry allocations until one succeed. */ for (; npackets > 1; npackets /= 2) { + stream->urb_size = psize * npackets;for (i =0 ; i <UVC_URBS ; ++i) { stream->urb_buffer[i] =usb_buffer_alloc ( - stream->dev->udev, psize * npackets, + stream->dev->udev, stream->urb_size, gfp_flags | __GFP_NOWARN, &stream->urb_dma[i]);if (!stream->urb_buffer[i]) {drivers/media/video/uvc/uvc_video.c +0
-1uvc_free_urb_buffers (stream);@@ -779,7 +780,6 @@ static int uvc_alloc_urb_buffers(struct uvc_streaming *stream, }if (i ==UVC_URBS ) { - stream->urb_size = psize * npackets;return npackets; } }
Signature · 3 lines
Regards, Laurent Pinchart