Skip to content

Commit 4974b79

Browse files
committed
ALSA: usb-audio: Don't call usb_set_interface() at trigger callback
The PCM trigger callback is atomic, hence we must not call a function like usb_set_interface() there. Calling it from there would lead to a kernel Oops. Fix it by moving the usb_set_interface() call to set_sync_endpoint(). Also, apply the snd_usb_set_interface_quirk() for consistency, too. Tested-by: Keith Milner <[email protected]> Tested-by: Dylan Robinson <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Takashi Iwai <[email protected]>
1 parent bc4e94a commit 4974b79

File tree

1 file changed

+13
-15
lines changed

1 file changed

+13
-15
lines changed

sound/usb/pcm.c

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -232,21 +232,6 @@ static int start_endpoints(struct snd_usb_substream *subs)
232232
!test_and_set_bit(SUBSTREAM_FLAG_SYNC_EP_STARTED, &subs->flags)) {
233233
struct snd_usb_endpoint *ep = subs->sync_endpoint;
234234

235-
if (subs->data_endpoint->iface != subs->sync_endpoint->iface ||
236-
subs->data_endpoint->altsetting != subs->sync_endpoint->altsetting) {
237-
err = usb_set_interface(subs->dev,
238-
subs->sync_endpoint->iface,
239-
subs->sync_endpoint->altsetting);
240-
if (err < 0) {
241-
clear_bit(SUBSTREAM_FLAG_SYNC_EP_STARTED, &subs->flags);
242-
dev_err(&subs->dev->dev,
243-
"%d:%d: cannot set interface (%d)\n",
244-
subs->sync_endpoint->iface,
245-
subs->sync_endpoint->altsetting, err);
246-
return -EIO;
247-
}
248-
}
249-
250235
dev_dbg(&subs->dev->dev, "Starting sync EP @%p\n", ep);
251236

252237
ep->sync_slave = subs->data_endpoint;
@@ -530,6 +515,19 @@ static int set_sync_endpoint(struct snd_usb_substream *subs,
530515

531516
subs->data_endpoint->sync_master = subs->sync_endpoint;
532517

518+
if (subs->data_endpoint->iface != subs->sync_endpoint->iface ||
519+
subs->data_endpoint->altsetting != subs->sync_endpoint->altsetting) {
520+
err = usb_set_interface(subs->dev,
521+
subs->sync_endpoint->iface,
522+
subs->sync_endpoint->altsetting);
523+
if (err < 0)
524+
return err;
525+
dev_dbg(&dev->dev, "setting usb interface %d:%d\n",
526+
subs->sync_endpoint->iface,
527+
subs->sync_endpoint->altsetting);
528+
snd_usb_set_interface_quirk(dev);
529+
}
530+
533531
return 0;
534532
}
535533

0 commit comments

Comments
 (0)