Skip to content

Commit a74f8d0

Browse files
committed
ALSA: usb-audio: Apply mutex around snd_usb_endpoint_set_params()
The protection with chip->mutex was lost after splitting snd_usb_endpoint_set_params() and snd_usb_endpoint_prepare(). Apply the same mutex again to the former function. Fixes: 2be79d5 ("ALSA: usb-audio: Split endpoint setups for hw_params and prepare (take#2)") Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Takashi Iwai <[email protected]>
1 parent 9902b30 commit a74f8d0

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

sound/usb/endpoint.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1337,10 +1337,11 @@ int snd_usb_endpoint_set_params(struct snd_usb_audio *chip,
13371337
const struct audioformat *fmt = ep->cur_audiofmt;
13381338
int err;
13391339

1340+
mutex_lock(&chip->mutex);
13401341
/* release old buffers, if any */
13411342
err = release_urbs(ep, false);
13421343
if (err < 0)
1343-
return err;
1344+
goto unlock;
13441345

13451346
ep->datainterval = fmt->datainterval;
13461347
ep->maxpacksize = fmt->maxpacksize;
@@ -1378,13 +1379,16 @@ int snd_usb_endpoint_set_params(struct snd_usb_audio *chip,
13781379
usb_audio_dbg(chip, "Set up %d URBS, ret=%d\n", ep->nurbs, err);
13791380

13801381
if (err < 0)
1381-
return err;
1382+
goto unlock;
13821383

13831384
/* some unit conversions in runtime */
13841385
ep->maxframesize = ep->maxpacksize / ep->cur_frame_bytes;
13851386
ep->curframesize = ep->curpacksize / ep->cur_frame_bytes;
13861387

1387-
return update_clock_ref_rate(chip, ep);
1388+
err = update_clock_ref_rate(chip, ep);
1389+
unlock:
1390+
mutex_unlock(&chip->mutex);
1391+
return err;
13881392
}
13891393

13901394
static int init_sample_rate(struct snd_usb_audio *chip,

0 commit comments

Comments
 (0)