media: hdpvr: fix locking and a missing msleep
authorHans Verkuil <hverkuil@xs4all.nl>
Thu, 20 Jun 2019 11:43:41 +0000 (07:43 -0400)
committerMauro Carvalho Chehab <mchehab+samsung@kernel.org>
Mon, 24 Jun 2019 19:02:01 +0000 (15:02 -0400)
commit6bc5a4a1927556ff9adce1aa95ea408c95453225
treeff8c7402c3a7636fb11b8876ab3198baeec5e51d
parent07d89227a983df957a6a7c56f7c040cde9ac571f
media: hdpvr: fix locking and a missing msleep

This driver has three locking issues:

- The wait_event_interruptible() condition calls hdpvr_get_next_buffer(dev)
  which uses a mutex, which is not allowed. Rewrite with list_empty_careful()
  that doesn't need locking.

- In hdpvr_read() the call to hdpvr_stop_streaming() didn't lock io_mutex,
  but it should have since stop_streaming expects that.

- In hdpvr_device_release() io_mutex was locked when calling flush_work(),
  but there it shouldn't take that mutex since the work done by flush_work()
  also wants to lock that mutex.

There are also two other changes (suggested by Keith):

- msecs_to_jiffies(4000); (a NOP) should have been msleep(4000).
- Change v4l2_dbg to v4l2_info to always log if streaming had to be restarted.

Reported-by: Keith Pyle <kpyle@austin.rr.com>
Suggested-by: Keith Pyle <kpyle@austin.rr.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
drivers/media/usb/hdpvr/hdpvr-video.c