ALSA: snd-usb: fix sync pipe check
PATCH 1/1 ALSA: snd-usb: fix sync pipe check
Fix a bogus sanity check for sync pipe in pcm.c. This flaw was introduced during the streaming logic refactorization.
While at it, improve the error messages that are generated in such cases.
Signed-off-by Daniel Mack <[email protected]>
Reported-and-tested-by <[email protected]>
--- sound/usb/pcm.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-)
sound/usb/pcm.c +11 -7
@@ -354,17 +354,21 @@ static int set_format(struct snd_usb_substream *subs, struct audioformat *fmt) (get_endpoint(alts, 1)->bLength >= USB_DT_ENDPOINT_AUDIO_SIZE && get_endpoint(alts, 1)->bSynchAddress != 0 && !implicit_fb)) { -snd_printk (KERN_ERR "%d:%d:%d : invalid synch pipe\n" , - dev->devnum, fmt->iface, fmt->altsetting); +snd_printk (KERN_ERR "%d:%d:%d : invalid sync pipe. bmAttributes %02x, bLength %d, bSynchAddress %02x\n" , + dev->devnum, fmt->iface, fmt->altsetting, +get_endpoint (alts,1 )->bmAttributes, +get_endpoint (alts,1 )->bLength, +get_endpoint (alts,1 )->bSynchAddress);return -EINVAL ; } ep =get_endpoint (alts,1 )->bEndpointAddress; -if (get_endpoint (alts,0 )->bLength >=USB_DT_ENDPOINT_AUDIO_SIZE && +if (!implicit_fb && +get_endpoint (alts,0 )->bLength >=USB_DT_ENDPOINT_AUDIO_SIZE && (( is_playback && ep != (unsigned int )(get_endpoint (alts,0 )->bSynchAddress |USB_DIR_IN )) || - (!is_playback && ep != (unsigned int )(get_endpoint (alts,0 )->bSynchAddress & ~USB_DIR_IN )) || - ( is_playback && !implicit_fb))) { -snd_printk (KERN_ERR "%d:%d:%d : invalid synch pipe\n" , - dev->devnum, fmt->iface, fmt->altsetting); + (!is_playback && ep != (unsigned int )(get_endpoint (alts,0 )->bSynchAddress & ~USB_DIR_IN )))) { +snd_printk (KERN_ERR "%d:%d:%d : invalid sync pipe. is_playback %d, ep %02x, bSynchAddress %02x\n" , + dev->devnum, fmt->iface, fmt->altsetting, + is_playback, ep,get_endpoint (alts,0 )->bSynchAddress);return -EINVAL ; }
Signature · 1 line
1.7.10.2
Takashi Iwai
AppliedAt Sun, 17 Jun 2012 13:44:27 +0200,
Quoted 8 lines · Daniel Mack
Fix a bogus sanity check for sync pipe in
pcm.c. This flaw was introduced during the streaming logic refactorization.While at it, improve the error messages that are generated in such cases.
Signed-off-by Daniel Mack <[email protected]>Reported-and-tested-by <[email protected]>
Thanks, applied.
Takashi
Quoted 45 lines
--- sound/usb/pcm.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-)sound/usb/pcm.c +11
-7@@ -354,17 +354,21 @@ static int set_format(struct snd_usb_substream *subs, struct audioformat *fmt) (get_endpoint(alts, 1)->bLength >= USB_DT_ENDPOINT_AUDIO_SIZE && get_endpoint(alts, 1)->bSynchAddress != 0 && !implicit_fb)) { -snd_printk (KERN_ERR "%d:%d:%d : invalid synch pipe\n" , - dev->devnum, fmt->iface, fmt->altsetting); +snd_printk (KERN_ERR "%d:%d:%d : invalid sync pipe. bmAttributes %02x, bLength %d, bSynchAddress %02x\n" , + dev->devnum, fmt->iface, fmt->altsetting, +get_endpoint (alts,1 )->bmAttributes, +get_endpoint (alts,1 )->bLength, +get_endpoint (alts,1 )->bSynchAddress);return -EINVAL ; } ep =get_endpoint (alts,1 )->bEndpointAddress; -if (get_endpoint (alts,0 )->bLength >=USB_DT_ENDPOINT_AUDIO_SIZE && +if (!implicit_fb && +get_endpoint (alts,0 )->bLength >=USB_DT_ENDPOINT_AUDIO_SIZE && (( is_playback && ep != (unsigned int )(get_endpoint (alts,0 )->bSynchAddress |USB_DIR_IN )) || - (!is_playback && ep != (unsigned int )(get_endpoint (alts,0 )->bSynchAddress & ~USB_DIR_IN )) || - ( is_playback && !implicit_fb))) { -snd_printk (KERN_ERR "%d:%d:%d : invalid synch pipe\n" , - dev->devnum, fmt->iface, fmt->altsetting); + (!is_playback && ep != (unsigned int )(get_endpoint (alts,0 )->bSynchAddress & ~USB_DIR_IN )))) { +snd_printk (KERN_ERR "%d:%d:%d : invalid sync pipe. is_playback %d, ep %02x, bSynchAddress %02x\n" , + dev->devnum, fmt->iface, fmt->altsetting, + is_playback, ep,get_endpoint (alts,0 )->bSynchAddress);return -EINVAL ; }Signature · 6 lines
1.7.10.2 _______________________________________________ Alsa-devel mailing list [email protected] http://mailman.alsa-project.org/mailman/listinfo/alsa-devel