[alsa-devel] [PATCH 2/3] ALSA: snd-usb: avoid dividing by zero on invalid input

Daniel Mack zonque at gmail.com
Thu Aug 4 15:56:27 CEST 2011


From: Nicolai Krakowiak <nicolai.krakowiak at gmail.com>

Signed-off-by: Nicolai Krakowiak <nicolai.krakowiak at gmail.com>
Acked-by: Daniel Mack <zonque at gmail.com>
Cc: stable at kernel.org
---
 sound/usb/mixer.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/sound/usb/mixer.c b/sound/usb/mixer.c
index d33a5a9..5ab345f 100644
--- a/sound/usb/mixer.c
+++ b/sound/usb/mixer.c
@@ -1191,6 +1191,11 @@ static int parse_audio_feature_unit(struct mixer_build *state, int unitid, void
 
 	if (state->mixer->protocol == UAC_VERSION_1) {
 		csize = hdr->bControlSize;
+		if (!csize) {
+			snd_printdd(KERN_ERR "usbaudio: unit %u: "
+				    "invalid bControlSize == 0\n", unitid);
+			return -EINVAL;
+		}
 		channels = (hdr->bLength - 7) / csize - 1;
 		bmaControls = hdr->bmaControls;
 	} else {
-- 
1.7.5.4



More information about the Alsa-devel mailing list