Re: help with Focusrite Scarlett 18i6 USB

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Jul 13, 2011 at 7:03 AM, Daniel Mack <zonque@xxxxxxxxx> wrote:
> Even though the root cause for your problem here is somewhere else, we
> indeed should prevent dividing by zero. Can you send the a new patch
> with only the first hunk of your "hack" (the one that checks for csize
> == 0) again with your Signed-off-by: line? I'll queue it up for you
> then.

I changed the snd_printdd to a KERN_ERR and split the line under 80
columns.  There's some additional cleanup that could happen with the
header->bLength, csize checks slightly below where this patch hits
(one of the length checks is redundant, as is the !csize check), but
I'm not well versed in the local style and didn't want to break
anything. =)

nicolai
From 83bcd097550a4494c6b3f362ebbc432249acde59 Mon Sep 17 00:00:00 2001
From: Nicolai Krakowiak <nicolai.krakowiak@xxxxxxxxx>
Date: Fri, 15 Jul 2011 23:05:10 -0700
Subject: [PATCH 1/1] ALSA: snd-usb: avoid dividing by zero on invalid input


Signed-off-by: Nicolai Krakowiak <nicolai.krakowiak@xxxxxxxxx>

diff --git a/sound/usb/mixer.c b/sound/usb/mixer.c
index c22fa76..ee9aa08 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.4.1

------------------------------------------------------------------------------
AppSumo Presents a FREE Video for the SourceForge Community by Eric 
Ries, the creator of the Lean Startup Methodology on "Lean Startup 
Secrets Revealed." This video shows you how to validate your ideas, 
optimize your ideas and identify your business strategy.
http://p.sf.net/sfu/appsumosfdev2dev
_______________________________________________
Alsa-user mailing list
Alsa-user@xxxxxxxxxxxxxxxxxxxxx
https://lists.sourceforge.net/lists/listinfo/alsa-user

[Index of Archives]     [ALSA Devel]     [Linux Audio Users]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]

  Powered by Linux