[alsa-devel] [PATCH RFC 10/10] ALSA: usb-audio: check alts is not NULL before adding ep

Eldad Zack eldad at fogrefinery.com
Fri Jul 19 20:23:30 CEST 2013


snd_usb_add_endpoint assumes alts is not NULL. Before passing alts,
check if it is the case (for future-proofing).
Since it is also an indication that a quirk is needed, remove the
redundant goto statements.

Signed-off-by: Eldad Zack <eldad at fogrefinery.com>
---
 sound/usb/pcm.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/sound/usb/pcm.c b/sound/usb/pcm.c
index 0704823..e70f70b 100644
--- a/sound/usb/pcm.c
+++ b/sound/usb/pcm.c
@@ -332,7 +332,7 @@ static int set_sync_ep_implicit_fb_quirk(struct snd_usb_substream *subs,
 					 struct usb_interface_descriptor *altsd,
 					 unsigned int attr)
 {
-	struct usb_host_interface *alts;
+	struct usb_host_interface *alts = NULL;
 	struct usb_interface *iface;
 	unsigned int ep;
 
@@ -350,7 +350,6 @@ static int set_sync_ep_implicit_fb_quirk(struct snd_usb_substream *subs,
 			return -EINVAL;
 
 		alts = &iface->altsetting[1];
-		goto add_sync_ep;
 		break;
 	case USB_ID(0x0763, 0x2080): /* M-Audio FastTrack Ultra */
 	case USB_ID(0x0763, 0x2081):
@@ -361,7 +360,6 @@ static int set_sync_ep_implicit_fb_quirk(struct snd_usb_substream *subs,
 			return -EINVAL;
 
 		alts = &iface->altsetting[1];
-		goto add_sync_ep;
 	}
 
 	if (USB_ID_VENDOR(subs->stream->chip->usb_id) == 0x0582) { /* Roland */
@@ -374,15 +372,13 @@ static int set_sync_ep_implicit_fb_quirk(struct snd_usb_substream *subs,
 						        &alts, &ep);
 			if (err < 0)
 				return err;
-
-			goto add_sync_ep;
 		}
 	}
 
 	/* No quirk */
-	return 0;
+	if (alts == NULL)
+		return 0;
 
-add_sync_ep:
 	subs->sync_endpoint = snd_usb_add_endpoint(subs->stream->chip,
 						   alts, ep, !subs->direction,
 						   SND_USB_ENDPOINT_TYPE_DATA);
-- 
1.8.1.5



More information about the Alsa-devel mailing list