diff options
author | Geoffrey D. Bennett <g@b4.vu> | 2023-12-19 20:38:09 +0300 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2023-12-29 17:39:27 +0300 |
commit | 993f7b42fa066b055e3a19b7f76ad8157c0927a0 (patch) | |
tree | 0b3f6e0c71cfe85142b8799590832b9bc0e25536 | |
parent | 04f8f053252b86c7583895c962d66747ecdc61b7 (diff) | |
download | linux-993f7b42fa066b055e3a19b7f76ad8157c0927a0.tar.xz |
ALSA: scarlett2: Add missing mutex lock around get meter levels
As scarlett2_meter_ctl_get() uses meter_level_map[], the data_mutex
should be locked while accessing it.
Signed-off-by: Geoffrey D. Bennett <g@b4.vu>
Fixes: 3473185f31df ("ALSA: scarlett2: Remap Level Meter values")
Link: https://lore.kernel.org/r/77e093c27402c83d0730681448fa4f57583349dd.1703001053.git.g@b4.vu
Signed-off-by: Takashi Iwai <tiwai@suse.de>
-rw-r--r-- | sound/usb/mixer_scarlett2.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/sound/usb/mixer_scarlett2.c b/sound/usb/mixer_scarlett2.c index 8a60c2169259..a3cbeba7bd24 100644 --- a/sound/usb/mixer_scarlett2.c +++ b/sound/usb/mixer_scarlett2.c @@ -3880,10 +3880,12 @@ static int scarlett2_meter_ctl_get(struct snd_kcontrol *kctl, u16 meter_levels[SCARLETT2_MAX_METERS]; int i, err; + mutex_lock(&private->data_mutex); + err = scarlett2_usb_get_meter_levels(elem->head.mixer, elem->channels, meter_levels); if (err < 0) - return err; + goto unlock; /* copy & translate from meter_levels[] using meter_level_map[] */ for (i = 0; i < elem->channels; i++) { @@ -3898,7 +3900,10 @@ static int scarlett2_meter_ctl_get(struct snd_kcontrol *kctl, ucontrol->value.integer.value[i] = value; } - return 0; +unlock: + mutex_unlock(&private->data_mutex); + + return err; } static const struct snd_kcontrol_new scarlett2_meter_ctl = { |