summaryrefslogtreecommitdiff
path: root/drivers/media/usb/pwc
diff options
context:
space:
mode:
authorHans Verkuil <hans.verkuil@cisco.com>2014-03-04 14:28:11 +0400
committerMauro Carvalho Chehab <m.chehab@samsung.com>2014-03-11 13:56:38 +0400
commit1a17948184a3320e0bb0aab561112211d2e9b7a8 (patch)
treea25e6526939a67a4bde8017a1b2db76981fd17be /drivers/media/usb/pwc
parent0647064293d745720fc62e2edc7734fa8af06adf (diff)
downloadlinux-1a17948184a3320e0bb0aab561112211d2e9b7a8.tar.xz
[media] pwc: do not decompress the image unless the state is DONE
There is no point in trying to decompress a captured frame unless the buffer state is OK. It won't be used in any other state, and in fact the contents of the buffer might well be corrupt. Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Diffstat (limited to 'drivers/media/usb/pwc')
-rw-r--r--drivers/media/usb/pwc/pwc-if.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/drivers/media/usb/pwc/pwc-if.c b/drivers/media/usb/pwc/pwc-if.c
index 1a27096b3f91..84a6720b1d00 100644
--- a/drivers/media/usb/pwc/pwc-if.c
+++ b/drivers/media/usb/pwc/pwc-if.c
@@ -619,12 +619,15 @@ static void buffer_finish(struct vb2_buffer *vb)
struct pwc_device *pdev = vb2_get_drv_priv(vb->vb2_queue);
struct pwc_frame_buf *buf = container_of(vb, struct pwc_frame_buf, vb);
- /*
- * Application has called dqbuf and is getting back a buffer we've
- * filled, take the pwc data we've stored in buf->data and decompress
- * it into a usable format, storing the result in the vb2_buffer
- */
- pwc_decompress(pdev, buf);
+ if (vb->state == VB2_BUF_STATE_DONE) {
+ /*
+ * Application has called dqbuf and is getting back a buffer
+ * we've filled, take the pwc data we've stored in buf->data
+ * and decompress it into a usable format, storing the result
+ * in the vb2_buffer.
+ */
+ pwc_decompress(pdev, buf);
+ }
}
static void buffer_cleanup(struct vb2_buffer *vb)