[alsa-devel] [PATCH v3 03/11] ALSA: usb-audio: prevent NULL dereference on stop trigger
Eldad Zack
eldad at fogrefinery.com
Sun Aug 25 17:43:11 CEST 2013
If an endpoint uses another endpoint for synchronization, and the
other endpoint is stopped, an oops will occur on NULL dereference.
Clearing the prepare/retire callbacks solves this issue.
v2: Thanks to Daniel Mack, fixed (an irnoic) NULL dereference when
the pcm substream is opened and closed immediately.
Signed-off-by: Eldad Zack <eldad at fogrefinery.com>
---
sound/usb/pcm.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/sound/usb/pcm.c b/sound/usb/pcm.c
index 9ec401a..4227d34 100644
--- a/sound/usb/pcm.c
+++ b/sound/usb/pcm.c
@@ -1199,6 +1199,11 @@ static int snd_usb_pcm_close(struct snd_pcm_substream *substream, int direction)
subs->interface = -1;
}
+ if (subs->data_endpoint) {
+ subs->data_endpoint->prepare_data_urb = NULL;
+ subs->data_endpoint->retire_data_urb = NULL;
+ }
+
subs->pcm_substream = NULL;
snd_usb_autosuspend(subs->stream->chip);
@@ -1525,6 +1530,8 @@ static int snd_usb_substream_playback_trigger(struct snd_pcm_substream *substrea
subs->running = 1;
return 0;
case SNDRV_PCM_TRIGGER_STOP:
+ subs->data_endpoint->prepare_data_urb = NULL;
+ subs->data_endpoint->retire_data_urb = NULL;
stop_endpoints(subs, false);
subs->running = 0;
return 0;
@@ -1555,6 +1562,7 @@ static int snd_usb_substream_capture_trigger(struct snd_pcm_substream *substream
subs->running = 1;
return 0;
case SNDRV_PCM_TRIGGER_STOP:
+ subs->data_endpoint->retire_data_urb = NULL;
stop_endpoints(subs, false);
subs->running = 0;
return 0;
--
1.8.1.5
More information about the Alsa-devel
mailing list