aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Carpenter <dan.carpenter@oracle.com>2013-09-13 04:07:13 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-09-17 10:39:28 -0400
commitc3cb718acc17f8e0d6b4b8d1f8ca9a20d1999159 (patch)
tree79b45433fe399c666f99e5e939b7dca89f18c5d2
parent650433b8b1a4a4a46250ad0c8f68b2e47671914d (diff)
staging: line6: add bounds check in snd_toneport_source_put()
"source" comes from the user in snd_ctl_elem_write() so it needs to be checked. Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Reviewed-by: Stefan Hajnoczi <stefanha@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/staging/line6/toneport.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/drivers/staging/line6/toneport.c b/drivers/staging/line6/toneport.c
index 2f44d56700af..776d3632dc7d 100644
--- a/drivers/staging/line6/toneport.c
+++ b/drivers/staging/line6/toneport.c
@@ -244,13 +244,17 @@ static int snd_toneport_source_put(struct snd_kcontrol *kcontrol,
244 struct snd_line6_pcm *line6pcm = snd_kcontrol_chip(kcontrol); 244 struct snd_line6_pcm *line6pcm = snd_kcontrol_chip(kcontrol);
245 struct usb_line6_toneport *toneport = 245 struct usb_line6_toneport *toneport =
246 (struct usb_line6_toneport *)line6pcm->line6; 246 (struct usb_line6_toneport *)line6pcm->line6;
247 unsigned int source;
247 248
248 if (ucontrol->value.enumerated.item[0] == toneport->source) 249 source = ucontrol->value.enumerated.item[0];
250 if (source >= ARRAY_SIZE(toneport_source_info))
251 return -EINVAL;
252 if (source == toneport->source)
249 return 0; 253 return 0;
250 254
251 toneport->source = ucontrol->value.enumerated.item[0]; 255 toneport->source = source;
252 toneport_send_cmd(toneport->line6.usbdev, 256 toneport_send_cmd(toneport->line6.usbdev,
253 toneport_source_info[toneport->source].code, 0x0000); 257 toneport_source_info[source].code, 0x0000);
254 return 1; 258 return 1;
255} 259}
256 260