diff options
author | Ming Lei <tom.leiming@gmail.com> | 2009-09-27 04:30:34 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2009-12-05 15:40:36 -0500 |
commit | fd1b6bbb4a54a232ae6a1e5e4a6fbe3507ed5142 (patch) | |
tree | 4896ef2b17e9e7928f2b53e98fd39d8c59a95c6e /drivers/media/video/uvc | |
parent | 716fdee110ceb816cca8c46c0890d08c5a1addb9 (diff) |
V4L/DVB (13153): uvcvideo: Fix uvc_alloc_urb_buffers()
This patch sets stream->urb_size as psize*npackets
before calling uvc_alloc_urb_buffers, which may fix
a possible failure of usb_buffer_free in case usb_buffer_alloc
returns NULL. The patch is based on the ideas below:
1,If usb_buffer_alloc can't allocate a buffer sucessfully,
uvc_free_urb_buffers will be called to free the allocated
buffers, and stream->urb_size is required to be passed to
usb_buffer_free;
2,uvc_free_urb_buffers can reset stream->urb_size.
This patch is against linux-v2.6.31-next-20090926.
Signed-off-by: Ming Lei <tom.leiming@gmail.com>
Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video/uvc')
-rw-r--r-- | drivers/media/video/uvc/uvc_video.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/media/video/uvc/uvc_video.c b/drivers/media/video/uvc/uvc_video.c index bb9fed669363..3369200a91d7 100644 --- a/drivers/media/video/uvc/uvc_video.c +++ b/drivers/media/video/uvc/uvc_video.c | |||
@@ -770,8 +770,9 @@ static int uvc_alloc_urb_buffers(struct uvc_streaming *stream, | |||
770 | /* Retry allocations until one succeed. */ | 770 | /* Retry allocations until one succeed. */ |
771 | for (; npackets > 1; npackets /= 2) { | 771 | for (; npackets > 1; npackets /= 2) { |
772 | for (i = 0; i < UVC_URBS; ++i) { | 772 | for (i = 0; i < UVC_URBS; ++i) { |
773 | stream->urb_size = psize * npackets; | ||
773 | stream->urb_buffer[i] = usb_buffer_alloc( | 774 | stream->urb_buffer[i] = usb_buffer_alloc( |
774 | stream->dev->udev, psize * npackets, | 775 | stream->dev->udev, stream->urb_size, |
775 | gfp_flags | __GFP_NOWARN, &stream->urb_dma[i]); | 776 | gfp_flags | __GFP_NOWARN, &stream->urb_dma[i]); |
776 | if (!stream->urb_buffer[i]) { | 777 | if (!stream->urb_buffer[i]) { |
777 | uvc_free_urb_buffers(stream); | 778 | uvc_free_urb_buffers(stream); |
@@ -780,7 +781,6 @@ static int uvc_alloc_urb_buffers(struct uvc_streaming *stream, | |||
780 | } | 781 | } |
781 | 782 | ||
782 | if (i == UVC_URBS) { | 783 | if (i == UVC_URBS) { |
783 | stream->urb_size = psize * npackets; | ||
784 | uvc_trace(UVC_TRACE_VIDEO, "Allocated %u URB buffers " | 784 | uvc_trace(UVC_TRACE_VIDEO, "Allocated %u URB buffers " |
785 | "of %ux%u bytes each.\n", UVC_URBS, npackets, | 785 | "of %ux%u bytes each.\n", UVC_URBS, npackets, |
786 | psize); | 786 | psize); |