ALSA: usb: Avoid VLA in mixer_us16x08.c
authorTakashi Iwai <tiwai@suse.de>
Tue, 30 May 2017 21:24:45 +0000 (23:24 +0200)
committerTakashi Iwai <tiwai@suse.de>
Wed, 31 May 2017 06:46:19 +0000 (08:46 +0200)
This is another attempt to work around the VLA used in
mixer_us16x08.c.  Basically the temporary array is used individually
for two cases, and we can declare locally in each block, instead of
hackish max() usage.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/usb/mixer_us16x08.c

index 442d8f7998e3af3e53d92289a81f3d63179e2ed9..26ed23b18b7774fd495f7ce90e51ec6dc8022e2d 100644 (file)
@@ -698,16 +698,18 @@ static int snd_us16x08_meter_get(struct snd_kcontrol *kcontrol,
        struct snd_usb_audio *chip = elem->head.mixer->chip;
        struct snd_us16x08_meter_store *store = elem->private_data;
        u8 meter_urb[64];
-       char tmp[max(sizeof(mix_init_msg1), sizeof(mix_init_msg2))];
 
        switch (kcontrol->private_value) {
-       case 0:
+       case 0: {
+               char tmp[sizeof(mix_init_msg1)];
+
                memcpy(tmp, mix_init_msg1, sizeof(mix_init_msg1));
                snd_us16x08_send_urb(chip, tmp, 4);
                snd_us16x08_recv_urb(chip, meter_urb,
                        sizeof(meter_urb));
                kcontrol->private_value++;
                break;
+       }
        case 1:
                snd_us16x08_recv_urb(chip, meter_urb,
                        sizeof(meter_urb));
@@ -718,7 +720,9 @@ static int snd_us16x08_meter_get(struct snd_kcontrol *kcontrol,
                        sizeof(meter_urb));
                kcontrol->private_value++;
                break;
-       case 3:
+       case 3: {
+               char tmp[sizeof(mix_init_msg2)];
+
                memcpy(tmp, mix_init_msg2, sizeof(mix_init_msg2));
                tmp[2] = snd_get_meter_comp_index(store);
                snd_us16x08_send_urb(chip, tmp, 10);
@@ -727,6 +731,7 @@ static int snd_us16x08_meter_get(struct snd_kcontrol *kcontrol,
                kcontrol->private_value = 0;
                break;
        }
+       }
 
        for (set = 0; set < 6; set++)
                get_meter_levels_from_urb(set, store, meter_urb);