[alsa-devel] [PATCH v8 1/1] ALSA: Tascam US-16x08 DSP mixer quirk

Takashi Iwai tiwai at suse.de
Thu Feb 16 12:09:26 CET 2017


On Thu, 16 Feb 2017 10:48:42 +0100,
OnkelDead wrote:
> 
> +static int snd_us16x08_route_get(struct snd_kcontrol *kcontrol,
> +	struct snd_ctl_elem_value *ucontrol)
> +{
> +	struct usb_mixer_elem_info *elem = kcontrol->private_data;
> +	int index = ucontrol->id.index;
> +
> +	/* route has no bias */
> +	ucontrol->value.integer.value[0] = elem->cache_val[index];

This should be ucontrol->value.enumerated.item[0], instead.

> +static int snd_us16x08_route_put(struct snd_kcontrol *kcontrol,
> +	struct snd_ctl_elem_value *ucontrol)
> +{
...
> +	/*  get the new value (no bias for routes) */
> +	val = ucontrol->value.integer.value[0];

Ditto.

> +	if (val < 2) {
> +		/* input comes from a master channel */
> +		val_org = val;
> +		buf[2] = 0x02;
> +	} else {
> +		/* input comes from a computer channel */
> +		buf[2] = 0x03;
> +		val_org = val - 2;
> +	}

Note that there is no value range check before passed to put callback,
thus you should put some sanity check before this evaluation,

	if (val < 0 || val >= 10)
		return -EINVAL;

The same is applied to other put callback with INTEGER type, too.

I could fix a trivial thing like the missing static in my side, but
the things like the above are a fundamental bug, so please fix and
resubmit.


thanks,

Takashi


More information about the Alsa-devel mailing list