Skip to content

Commit 19418ed

Browse files
tiwaigregkh
authored andcommitted
ALSA: usb-audio: scarlett2: Fix wrong resume call
commit 785b6f2 upstream. The current way of the scarlett2 mixer code managing the usb_mixer_elem_info object is wrong in two ways: it passes its internal index to the head.id field, and the val_type field is uninitialized. This ended up with the wrong execution at the resume because a bogus unit id is passed wrongly. Also, in the later code extensions, we'll have more mixer elements, and passing the index will overflow the unit id size (of 256). This patch corrects those issues. It introduces a new value type, USB_MIXER_BESPOKEN, which indicates a non-standard mixer element, and use this type for all scarlett2 mixer elements, as well as initializing the fixed unit id 0 for avoiding the overflow. Tested-by: Geoffrey D. Bennett <g@b4.vu> Signed-off-by: Geoffrey D. Bennett <g@b4.vu> Cc: <stable@vger.kernel.org> Link: https://lore.kernel.org/r/49721219f45b7e175e729b0d9d9c142fd8f4342a.1624379707.git.g@b4.vu Signed-off-by: Takashi Iwai <tiwai@suse.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 5c4d51b commit 19418ed

3 files changed

Lines changed: 10 additions & 1 deletion

File tree

‎sound/usb/mixer.c‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3631,6 +3631,9 @@ static int restore_mixer_value(struct usb_mixer_elem_list *list)
36313631
struct usb_mixer_elem_info *cval = mixer_elem_list_to_info(list);
36323632
int c, err, idx;
36333633

3634+
if (cval->val_type == USB_MIXER_BESPOKEN)
3635+
return 0;
3636+
36343637
if (cval->cmask) {
36353638
idx = 0;
36363639
for (c = 0; c < MAX_CHANNELS; c++) {

‎sound/usb/mixer.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ enum {
5555
USB_MIXER_U16,
5656
USB_MIXER_S32,
5757
USB_MIXER_U32,
58+
USB_MIXER_BESPOKEN, /* non-standard type */
5859
};
5960

6061
typedef void (*usb_mixer_elem_dump_func_t)(struct snd_info_buffer *buffer,

‎sound/usb/mixer_scarlett_gen2.c‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -949,10 +949,15 @@ static int scarlett2_add_new_ctl(struct usb_mixer_interface *mixer,
949949
if (!elem)
950950
return -ENOMEM;
951951

952+
/* We set USB_MIXER_BESPOKEN type, so that the core USB mixer code
953+
* ignores them for resume and other operations.
954+
* Also, the head.id field is set to 0, as we don't use this field.
955+
*/
952956
elem->head.mixer = mixer;
953957
elem->control = index;
954-
elem->head.id = index;
958+
elem->head.id = 0;
955959
elem->channels = channels;
960+
elem->val_type = USB_MIXER_BESPOKEN;
956961

957962
kctl = snd_ctl_new1(ncontrol, elem);
958963
if (!kctl) {

0 commit comments

Comments
 (0)