All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] ALSA: snd-usb: mixer: propagate errors up the call chain
@ 2013-03-19 20:09 Daniel Mack
  2013-03-19 20:09 ` [PATCH 2/2] ALSA: snd-usb: mixer: ignore -EINVAL in snd_usb_mixer_controls() Daniel Mack
  2013-03-20  7:45 ` [PATCH 1/2] ALSA: snd-usb: mixer: propagate errors up the call chain Takashi Iwai
  0 siblings, 2 replies; 3+ messages in thread
From: Daniel Mack @ 2013-03-19 20:09 UTC (permalink / raw)
  To: alsa-devel; +Cc: tiwai, hegge, clemens, Daniel Mack

In check_input_term() and parse_audio_feature_unit(), propagate the
error value that has been returned by a failing function instead of
-EINVAL. That helps cleaning up the error pathes in the mixer.

Signed-off-by: Daniel Mack <zonque@gmail.com>
---
 sound/usb/mixer.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/sound/usb/mixer.c b/sound/usb/mixer.c
index 638e7f7..db30d02 100644
--- a/sound/usb/mixer.c
+++ b/sound/usb/mixer.c
@@ -715,8 +715,9 @@ static int check_input_term(struct mixer_build *state, int id, struct usb_audio_
 		case UAC2_CLOCK_SELECTOR: {
 			struct uac_selector_unit_descriptor *d = p1;
 			/* call recursively to retrieve the channel info */
-			if (check_input_term(state, d->baSourceID[0], term) < 0)
-				return -ENODEV;
+			err = check_input_term(state, d->baSourceID[0], term);
+			if (err < 0)
+				return err;
 			term->type = d->bDescriptorSubtype << 16; /* virtual type */
 			term->id = id;
 			term->name = uac_selector_unit_iSelector(d);
@@ -1356,8 +1357,9 @@ static int parse_audio_feature_unit(struct mixer_build *state, int unitid, void
 		return err;
 
 	/* determine the input source type and name */
-	if (check_input_term(state, hdr->bSourceID, &iterm) < 0)
-		return -EINVAL;
+	err = check_input_term(state, hdr->bSourceID, &iterm);
+	if (err < 0)
+		return err;
 
 	master_bits = snd_usb_combine_bytes(bmaControls, csize);
 	/* master configuration quirks */
-- 
1.8.1.4

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH 2/2] ALSA: snd-usb: mixer: ignore -EINVAL in snd_usb_mixer_controls()
  2013-03-19 20:09 [PATCH 1/2] ALSA: snd-usb: mixer: propagate errors up the call chain Daniel Mack
@ 2013-03-19 20:09 ` Daniel Mack
  2013-03-20  7:45 ` [PATCH 1/2] ALSA: snd-usb: mixer: propagate errors up the call chain Takashi Iwai
  1 sibling, 0 replies; 3+ messages in thread
From: Daniel Mack @ 2013-03-19 20:09 UTC (permalink / raw)
  To: alsa-devel; +Cc: tiwai, hegge, clemens, Daniel Mack

Creation of individual mixer controls may fail, but that shouldn't cause
the entire mixer creation to fail. Even worse, if the mixer creation
fails, that will error out the entire device probing.

All the functions called by parse_audio_unit() should return -EINVAL if
they find descriptors that are unsupported or believed to be malformed,
so we can safely handle this error code as a non-fatal condition in
snd_usb_mixer_controls().

That fixes a long standing bug which is commonly worked around by
adding quirks which make the driver ignore entire interfaces. Some of
them might now be unnecessary.

Signed-off-by: Daniel Mack <zonque@gmail.com>
Reported-and-tested-by: Rodolfo Thomazelli <pe.soberbo@gmail.com>
---
 sound/usb/mixer.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/sound/usb/mixer.c b/sound/usb/mixer.c
index db30d02..ac833f0 100644
--- a/sound/usb/mixer.c
+++ b/sound/usb/mixer.c
@@ -2120,7 +2120,7 @@ static int snd_usb_mixer_controls(struct usb_mixer_interface *mixer)
 			state.oterm.type = le16_to_cpu(desc->wTerminalType);
 			state.oterm.name = desc->iTerminal;
 			err = parse_audio_unit(&state, desc->bSourceID);
-			if (err < 0)
+			if (err < 0 && err != -EINVAL)
 				return err;
 		} else { /* UAC_VERSION_2 */
 			struct uac2_output_terminal_descriptor *desc = p;
@@ -2132,12 +2132,12 @@ static int snd_usb_mixer_controls(struct usb_mixer_interface *mixer)
 			state.oterm.type = le16_to_cpu(desc->wTerminalType);
 			state.oterm.name = desc->iTerminal;
 			err = parse_audio_unit(&state, desc->bSourceID);
-			if (err < 0)
+			if (err < 0 && err != -EINVAL)
 				return err;
 
 			/* for UAC2, use the same approach to also add the clock selectors */
 			err = parse_audio_unit(&state, desc->bCSourceID);
-			if (err < 0)
+			if (err < 0 && err != -EINVAL)
 				return err;
 		}
 	}
-- 
1.8.1.4

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH 1/2] ALSA: snd-usb: mixer: propagate errors up the call chain
  2013-03-19 20:09 [PATCH 1/2] ALSA: snd-usb: mixer: propagate errors up the call chain Daniel Mack
  2013-03-19 20:09 ` [PATCH 2/2] ALSA: snd-usb: mixer: ignore -EINVAL in snd_usb_mixer_controls() Daniel Mack
@ 2013-03-20  7:45 ` Takashi Iwai
  1 sibling, 0 replies; 3+ messages in thread
From: Takashi Iwai @ 2013-03-20  7:45 UTC (permalink / raw)
  To: Daniel Mack; +Cc: hegge, alsa-devel, clemens

At Tue, 19 Mar 2013 21:09:24 +0100,
Daniel Mack wrote:
> 
> In check_input_term() and parse_audio_feature_unit(), propagate the
> error value that has been returned by a failing function instead of
> -EINVAL. That helps cleaning up the error pathes in the mixer.
> 
> Signed-off-by: Daniel Mack <zonque@gmail.com>

Applied both patches now with Cc to stable.
Thanks.


Takashi


> ---
>  sound/usb/mixer.c | 10 ++++++----
>  1 file changed, 6 insertions(+), 4 deletions(-)
> 
> diff --git a/sound/usb/mixer.c b/sound/usb/mixer.c
> index 638e7f7..db30d02 100644
> --- a/sound/usb/mixer.c
> +++ b/sound/usb/mixer.c
> @@ -715,8 +715,9 @@ static int check_input_term(struct mixer_build *state, int id, struct usb_audio_
>  		case UAC2_CLOCK_SELECTOR: {
>  			struct uac_selector_unit_descriptor *d = p1;
>  			/* call recursively to retrieve the channel info */
> -			if (check_input_term(state, d->baSourceID[0], term) < 0)
> -				return -ENODEV;
> +			err = check_input_term(state, d->baSourceID[0], term);
> +			if (err < 0)
> +				return err;
>  			term->type = d->bDescriptorSubtype << 16; /* virtual type */
>  			term->id = id;
>  			term->name = uac_selector_unit_iSelector(d);
> @@ -1356,8 +1357,9 @@ static int parse_audio_feature_unit(struct mixer_build *state, int unitid, void
>  		return err;
>  
>  	/* determine the input source type and name */
> -	if (check_input_term(state, hdr->bSourceID, &iterm) < 0)
> -		return -EINVAL;
> +	err = check_input_term(state, hdr->bSourceID, &iterm);
> +	if (err < 0)
> +		return err;
>  
>  	master_bits = snd_usb_combine_bytes(bmaControls, csize);
>  	/* master configuration quirks */
> -- 
> 1.8.1.4
> 
> _______________________________________________
> Alsa-devel mailing list
> Alsa-devel@alsa-project.org
> http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2013-03-20  7:45 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-03-19 20:09 [PATCH 1/2] ALSA: snd-usb: mixer: propagate errors up the call chain Daniel Mack
2013-03-19 20:09 ` [PATCH 2/2] ALSA: snd-usb: mixer: ignore -EINVAL in snd_usb_mixer_controls() Daniel Mack
2013-03-20  7:45 ` [PATCH 1/2] ALSA: snd-usb: mixer: propagate errors up the call chain Takashi Iwai

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.