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

[media] pwc: poll(): Check that the device has not beem claimed for streaming already

Some apps which use read() start the streaming through a call to poll(),
this means that if another app has already claimed the device for streaming
(through for example a s_fmt, or a reqbufs), that the poll should fail instead
of getting passed through to vb2_poll.

We only check for this when the app is polling for reads, so that ctrl events
still work.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>

authored by

Hans de Goede and committed by
Mauro Carvalho Chehab
296da3cd 0bf0f713

+9
+9
drivers/media/video/pwc/pwc-if.c
··· 625 625 static unsigned int pwc_video_poll(struct file *file, poll_table *wait) 626 626 { 627 627 struct pwc_device *pdev = video_drvdata(file); 628 + unsigned long req_events = poll_requested_events(wait); 628 629 629 630 if (!pdev->udev) 630 631 return POLL_ERR; 632 + 633 + if ((req_events & (POLLIN | POLLRDNORM)) && 634 + pdev->vb_queue.num_buffers == 0 && 635 + !pdev->iso_init) { 636 + /* This poll will start a read stream, check capt_file */ 637 + if (pwc_test_n_set_capt_file(pdev, file)) 638 + return POLL_ERR; 639 + } 631 640 632 641 return vb2_poll(&pdev->vb_queue, file, wait); 633 642 }