[PATCH] media: cx231xx: Use snd_card_free_when_closed() instead of snd_card_free().

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



cx231xx_close_extension and hence cx231xx_audio_fini() are called with the
cx231xx device lock held, but snd_cx231xx_pcm_close() also grabs that mutex
when closing the file on behalf of arecord. There seems to be no reason to
wait for sound card resources to be released, so let the release be
asynchronous.

Tested with a Hauppauge 955Q (2040:b123) and Linux 5.9.6; the hang described in
the bug no longer occurs and disconnecting the device correctly terminates
arecord with ENODEV.

Fixes: https://bugzilla.kernel.org/show_bug.cgi?id=204087
Signed-off-by: Zebediah Figura <zfigura@xxxxxxxxxxxxxxx>
---
On the model of the USB audio driver (among others), I am inclined to believe
this is a correct approach. I have also tried to check for any potential
use-after-free bugs that might occur as a result of this patch, and been unable
to easily find any. However, as a new contributor, I am not familiar with the
USB, ALSA, or DVB frameworks, and there is a good chance that I have missed
something.

 drivers/media/usb/cx231xx/cx231xx-audio.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/usb/cx231xx/cx231xx-audio.c b/drivers/media/usb/cx231xx/cx231xx-audio.c
index de42db6f6ad1..9c71b32552df 100644
--- a/drivers/media/usb/cx231xx/cx231xx-audio.c
+++ b/drivers/media/usb/cx231xx/cx231xx-audio.c
@@ -670,7 +670,7 @@ static int cx231xx_audio_fini(struct cx231xx *dev)
 	}
 
 	if (dev->adev.sndcard) {
-		snd_card_free(dev->adev.sndcard);
+		snd_card_free_when_closed(dev->adev.sndcard);
 		kfree(dev->adev.alt_max_pkt_size);
 		dev->adev.sndcard = NULL;
 	}
-- 
2.29.2




[Index of Archives]     [Linux Input]     [Video for Linux]     [Gstreamer Embedded]     [Mplayer Users]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]

  Powered by Linux