Re: [PATCH 4/5] media: uvcvideo: Protect uvc queue file operations against disconnect

Guenter Roeck
2020-09-01T16:59:05Z

On 9/1/20 9:51 AM, kernel test robot wrote:
> Hi Guenter,
>
> I love your patch! Perhaps something to improve:
>
> [auto build test WARNING on linuxtv-media/master]
> [also build test WARNING on v5.9-rc3 next-20200828]
> [If your patch is applied to the wrong git tree, kindly drop us a note.
> And when submitting patch, we suggest to use '--base' as documented in
> https://git-scm.com/docs/git-format-patch]
>
> url: https://github.com/0day-ci/linux/commits/Guenter-Roeck/media-uvcvideo-Fix-race-conditions/20200830-230715
> base: git://linuxtv.org/media_tree.git master
> config: x86_64-randconfig-s031-20200901 (attached as .config)
> compiler: gcc-9 (Debian 9.3.0-15) 9.3.0
> reproduce:
> # apt-get install sparse
> # sparse version: v0.6.2-191-g10164920-dirty
> # save the attached .config to linux build tree
> make W=1 C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' ARCH=x86_64
>
> If you fix the issue, kindly add following tag as appropriate
> Reported-by: kernel test robot <lkp@intel.com>
>
>
> sparse warnings: (new ones prefixed by >>)
>
>>> drivers/media/usb/uvc/uvc_queue.c:402:21: sparse: sparse: incorrect type in assignment (different base types) @@ expected restricted __poll_t [usertype] ret @@ got int @@
>>> drivers/media/usb/uvc/uvc_queue.c:402:21: sparse: expected restricted __poll_t [usertype] ret
>>> drivers/media/usb/uvc/uvc_queue.c:402:21: sparse: got int
>
> # https://github.com/0day-ci/linux/commit/9128827e77bc077a6fefd3ca886a8466e84f7154
> git remote add linux-review https://github.com/0day-ci/linux
> git fetch --no-tags linux-review Guenter-Roeck/media-uvcvideo-Fix-race-conditions/20200830-230715
> git checkout 9128827e77bc077a6fefd3ca886a8466e84f7154
> vim +402 drivers/media/usb/uvc/uvc_queue.c
>
> 393
> 394 __poll_t uvc_queue_poll(struct uvc_video_queue *queue, struct file *file,
> 395 poll_table *wait)
> 396 {
> 397 struct uvc_streaming *stream = uvc_queue_to_stream(queue);
> 398 __poll_t ret;
> 399
> 400 mutex_lock(&queue->mutex);
> 401 if (!video_is_registered(&stream->vdev)) {
> > 402 ret = -ENODEV;

Looks like this has to return EPOLLERR. I'll make that change in v2.

Guenter

> 403 goto unlock;
> 404 }
> 405 ret = vb2_poll(&queue->queue, file, wait);
> 406 unlock:
> 407 mutex_unlock(&queue->mutex);
> 408
> 409 return ret;
> 410 }
> 411
>
> ---
> 0-DAY CI Kernel Test Service, Intel Corporation
> https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
>