All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] sound/usb: fix to release stream resources from media_snd_device_delete()
@ 2016-03-19  2:50 Shuah Khan
  2016-03-19  2:57 ` Mauro Carvalho Chehab
  2016-03-19 12:10   ` Mauro Carvalho Chehab
  0 siblings, 2 replies; 17+ messages in thread
From: Shuah Khan @ 2016-03-19  2:50 UTC (permalink / raw)
  To: mchehab, tiwai, perex; +Cc: Shuah Khan, linux-media, alsa-devel, linux-kernel

Fix to release stream resources from media_snd_device_delete() before
media device is unregistered. Without this change, stream resource free
is attempted after the media device is unregistered which would result
in use-after-free errors.

Signed-off-by: Shuah Khan <shuahkh@osg.samsung.com>
---

- Ran bind/unbind loop (1000 iteration) test on snd-usb-audio
  while running mc_nextgen_test loop (1000 iterations) in parallel.
- Ran bind/unbind and rmmod/modprobe tests on both drivers. Also
  generated graphs when after bind/unbind, rmmod/modprobe. Graphs
  look good.
- Note: Please apply the following patch to fix memory leak:
  sound/usb: Fix memory leak in media_snd_stream_delete() during unbind
  https://lkml.org/lkml/2016/3/16/1050

 sound/usb/media.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/sound/usb/media.c b/sound/usb/media.c
index de4a815..e35af88 100644
--- a/sound/usb/media.c
+++ b/sound/usb/media.c
@@ -301,6 +301,13 @@ int media_snd_device_create(struct snd_usb_audio *chip,
 void media_snd_device_delete(struct snd_usb_audio *chip)
 {
 	struct media_device *mdev = chip->media_dev;
+	struct snd_usb_stream *stream;
+
+	/* release resources */
+	list_for_each_entry(stream, &chip->pcm_list, list) {
+		media_snd_stream_delete(&stream->substream[0]);
+		media_snd_stream_delete(&stream->substream[1]);
+	}
 
 	media_snd_mixer_delete(chip);
 
-- 
2.5.0

^ permalink raw reply related	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2016-03-22 17:37 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-03-19  2:50 [PATCH] sound/usb: fix to release stream resources from media_snd_device_delete() Shuah Khan
2016-03-19  2:57 ` Mauro Carvalho Chehab
2016-03-19 10:39   ` Mauro Carvalho Chehab
2016-03-19 13:25     ` Shuah Khan
2016-03-19 13:25       ` Shuah Khan
2016-03-19 12:10 ` Mauro Carvalho Chehab
2016-03-19 12:10   ` Mauro Carvalho Chehab
2016-03-19 13:31   ` Shuah Khan
2016-03-19 13:31     ` Shuah Khan
2016-03-22  4:01     ` Shuah Khan
2016-03-22  4:01       ` Shuah Khan
2016-03-22 13:03       ` Shuah Khan
2016-03-22 13:03         ` Shuah Khan
2016-03-22 17:29         ` Shuah Khan
2016-03-22 17:29           ` Shuah Khan
2016-03-22 17:37           ` Mauro Carvalho Chehab
2016-03-22 17:37             ` Mauro Carvalho Chehab

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.