Commit f8dd4af6 authored by Laurent Pinchart's avatar Laurent Pinchart Committed by Mauro Carvalho Chehab

V4L/DVB (10101): uvcvideo: Fix bulk URB processing when the header is erroneous

When the first bulk URB of a video payload contains an erroneous header, or
when no V4L2 buffer is available, the whole payload must be dropped. Change
the skip logic to drop all bulk URBs until the end of the payload instead of
the first one only.
Signed-off-by: default avatarLaurent Pinchart <laurent.pinchart@skynet.be>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent 4e96fd08
...@@ -368,7 +368,7 @@ static int uvc_video_decode_start(struct uvc_video_device *video, ...@@ -368,7 +368,7 @@ static int uvc_video_decode_start(struct uvc_video_device *video,
/* Synchronize to the input stream by waiting for the FID bit to be /* Synchronize to the input stream by waiting for the FID bit to be
* toggled when the the buffer state is not UVC_BUF_STATE_ACTIVE. * toggled when the the buffer state is not UVC_BUF_STATE_ACTIVE.
* queue->last_fid is initialized to -1, so the first isochronous * video->last_fid is initialized to -1, so the first isochronous
* frame will always be in sync. * frame will always be in sync.
* *
* If the device doesn't toggle the FID bit, invert video->last_fid * If the device doesn't toggle the FID bit, invert video->last_fid
...@@ -395,7 +395,7 @@ static int uvc_video_decode_start(struct uvc_video_device *video, ...@@ -395,7 +395,7 @@ static int uvc_video_decode_start(struct uvc_video_device *video,
* last payload can be lost anyway). We thus must check if the FID has * last payload can be lost anyway). We thus must check if the FID has
* been toggled. * been toggled.
* *
* queue->last_fid is initialized to -1, so the first isochronous * video->last_fid is initialized to -1, so the first isochronous
* frame will never trigger an end of frame detection. * frame will never trigger an end of frame detection.
* *
* Empty buffers (bytesused == 0) don't trigger end of frame detection * Empty buffers (bytesused == 0) don't trigger end of frame detection
...@@ -512,7 +512,7 @@ static void uvc_video_decode_bulk(struct urb *urb, ...@@ -512,7 +512,7 @@ static void uvc_video_decode_bulk(struct urb *urb,
/* If the URB is the first of its payload, decode and save the /* If the URB is the first of its payload, decode and save the
* header. * header.
*/ */
if (video->bulk.header_size == 0) { if (video->bulk.header_size == 0 && !video->bulk.skip_payload) {
do { do {
ret = uvc_video_decode_start(video, buf, mem, len); ret = uvc_video_decode_start(video, buf, mem, len);
if (ret == -EAGAIN) if (ret == -EAGAIN)
...@@ -522,14 +522,13 @@ static void uvc_video_decode_bulk(struct urb *urb, ...@@ -522,14 +522,13 @@ static void uvc_video_decode_bulk(struct urb *urb,
/* If an error occured skip the rest of the payload. */ /* If an error occured skip the rest of the payload. */
if (ret < 0 || buf == NULL) { if (ret < 0 || buf == NULL) {
video->bulk.skip_payload = 1; video->bulk.skip_payload = 1;
return; } else {
} memcpy(video->bulk.header, mem, ret);
video->bulk.header_size = ret;
video->bulk.header_size = ret; mem += ret;
memcpy(video->bulk.header, mem, video->bulk.header_size); len -= ret;
}
mem += ret;
len -= ret;
} }
/* The buffer queue might have been cancelled while a bulk transfer /* The buffer queue might have been cancelled while a bulk transfer
......
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