Skip to content

Commit

Permalink
staging: line6: add bounds check in snd_toneport_source_put()
Browse files Browse the repository at this point in the history
"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>
  • Loading branch information
Dan Carpenter authored and Greg Kroah-Hartman committed Sep 17, 2013
1 parent 650433b commit c3cb718
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions drivers/staging/line6/toneport.c
Original file line number Diff line number Diff line change
Expand Up @@ -244,13 +244,17 @@ static int snd_toneport_source_put(struct snd_kcontrol *kcontrol,
struct snd_line6_pcm *line6pcm = snd_kcontrol_chip(kcontrol);
struct usb_line6_toneport *toneport =
(struct usb_line6_toneport *)line6pcm->line6;
unsigned int source;

if (ucontrol->value.enumerated.item[0] == toneport->source)
source = ucontrol->value.enumerated.item[0];
if (source >= ARRAY_SIZE(toneport_source_info))
return -EINVAL;
if (source == toneport->source)
return 0;

toneport->source = ucontrol->value.enumerated.item[0];
toneport->source = source;
toneport_send_cmd(toneport->line6.usbdev,
toneport_source_info[toneport->source].code, 0x0000);
toneport_source_info[source].code, 0x0000);
return 1;
}

Expand Down

0 comments on commit c3cb718

Please sign in to comment.