Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[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>

authored by

Hans Verkuil and committed by
Mauro Carvalho Chehab
1a179481 06470642

+9 -6
+9 -6
drivers/media/usb/pwc/pwc-if.c
··· 619 619 struct pwc_device *pdev = vb2_get_drv_priv(vb->vb2_queue); 620 620 struct pwc_frame_buf *buf = container_of(vb, struct pwc_frame_buf, vb); 621 621 622 - /* 623 - * Application has called dqbuf and is getting back a buffer we've 624 - * filled, take the pwc data we've stored in buf->data and decompress 625 - * it into a usable format, storing the result in the vb2_buffer 626 - */ 627 - pwc_decompress(pdev, buf); 622 + if (vb->state == VB2_BUF_STATE_DONE) { 623 + /* 624 + * Application has called dqbuf and is getting back a buffer 625 + * we've filled, take the pwc data we've stored in buf->data 626 + * and decompress it into a usable format, storing the result 627 + * in the vb2_buffer. 628 + */ 629 + pwc_decompress(pdev, buf); 630 + } 628 631 } 629 632 630 633 static void buffer_cleanup(struct vb2_buffer *vb)