From: Takashi Iwai <tiwai@suse.de>
To: Dan Carpenter <dan.carpenter@oracle.com>
Cc: Jaroslav Kysela <perex@perex.cz>,
Sudip Mukherjee <sudipm.mukherjee@gmail.com>,
Sachin Kamat <sachin.kamat@samsung.com>,
alsa-devel@alsa-project.org, kernel-janitors@vger.kernel.org
Subject: Re: [patch] ALSA: echoaudio: read past end of array
Date: Mon, 23 Mar 2015 14:00:38 +0100 [thread overview]
Message-ID: <s5hpp7z50nd.wl-tiwai@suse.de> (raw)
In-Reply-To: <20150323094131.GE558@mwanda>
At Mon, 23 Mar 2015 12:41:31 +0300,
Dan Carpenter wrote:
>
> We need to cap "ucontrol->id.index / num_busses_in(chip)" so the we
> don't read beyond the end of the array.
>
> I also adding a check on "in" and changing the type in
> snd_echo_mixer_put() from short to unsigned int. Those changes are done
> for symmetry and are cosmetic.
>
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Applied, thanks.
Takashi
>
> diff --git a/sound/pci/echoaudio/echoaudio.c b/sound/pci/echoaudio/echoaudio.c
> index a962de0..862db9a 100644
> --- a/sound/pci/echoaudio/echoaudio.c
> +++ b/sound/pci/echoaudio/echoaudio.c
> @@ -1283,12 +1283,14 @@ static int snd_echo_mixer_info(struct snd_kcontrol *kcontrol,
> static int snd_echo_mixer_get(struct snd_kcontrol *kcontrol,
> struct snd_ctl_elem_value *ucontrol)
> {
> - struct echoaudio *chip;
> + struct echoaudio *chip = snd_kcontrol_chip(kcontrol);
> + unsigned int out = ucontrol->id.index / num_busses_in(chip);
> + unsigned int in = ucontrol->id.index % num_busses_in(chip);
>
> - chip = snd_kcontrol_chip(kcontrol);
> - ucontrol->value.integer.value[0] =
> - chip->monitor_gain[ucontrol->id.index / num_busses_in(chip)]
> - [ucontrol->id.index % num_busses_in(chip)];
> + if (out >= ECHO_MAXAUDIOOUTPUTS || in >= ECHO_MAXAUDIOINPUTS)
> + return -EINVAL;
> +
> + ucontrol->value.integer.value[0] = chip->monitor_gain[out][in];
> return 0;
> }
>
> @@ -1297,12 +1299,14 @@ static int snd_echo_mixer_put(struct snd_kcontrol *kcontrol,
> {
> struct echoaudio *chip;
> int changed, gain;
> - short out, in;
> + unsigned int out, in;
>
> changed = 0;
> chip = snd_kcontrol_chip(kcontrol);
> out = ucontrol->id.index / num_busses_in(chip);
> in = ucontrol->id.index % num_busses_in(chip);
> + if (out >= ECHO_MAXAUDIOOUTPUTS || in >= ECHO_MAXAUDIOINPUTS)
> + return -EINVAL;
> gain = ucontrol->value.integer.value[0];
> if (gain < ECHOGAIN_MINOUT || gain > ECHOGAIN_MAXOUT)
> return -EINVAL;
>
prev parent reply other threads:[~2015-03-23 13:00 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-23 9:41 [patch] ALSA: echoaudio: read past end of array Dan Carpenter
2015-03-23 13:00 ` Takashi Iwai [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=s5hpp7z50nd.wl-tiwai@suse.de \
--to=tiwai@suse.de \
--cc=alsa-devel@alsa-project.org \
--cc=dan.carpenter@oracle.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=perex@perex.cz \
--cc=sachin.kamat@samsung.com \
--cc=sudipm.mukherjee@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox