]> git.baikalelectronics.ru Git - kernel.git/commit
media: usbtv: Fix deadlock on suspend
authorMaxim Mikityanskiy <maxtram95@gmail.com>
Fri, 5 Feb 2021 22:51:39 +0000 (23:51 +0100)
committerMauro Carvalho Chehab <mchehab+huawei@kernel.org>
Thu, 11 Mar 2021 10:40:28 +0000 (11:40 +0100)
commitef2fc720caa75ad5fba608fb7cbe3930feaf583c
tree342ad489b0a35d0957410ccad3ccbe49923a12d2
parentdf3fe9caeb37250b5c0956b35c00cd367e94ed11
media: usbtv: Fix deadlock on suspend

usbtv doesn't support power management, so on system suspend the
.disconnect callback of the driver is called. The teardown sequence
includes a call to snd_card_free. Its implementation waits until the
refcount of the sound card device drops to zero, however, if its file is
open, snd_card_file_add takes a reference, which can't be dropped during
the suspend, because the userspace processes are already frozen at this
point. snd_card_free waits for completion forever, leading to a hang on
suspend.

This commit fixes this deadlock condition by replacing snd_card_free
with snd_card_free_when_closed, that doesn't wait until all references
are released, allowing suspend to progress.

Fixes: 965466b279ae ("[media] usbtv: add audio support")
Signed-off-by: Maxim Mikityanskiy <maxtram95@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
drivers/media/usb/usbtv/usbtv-audio.c