All of lore.kernel.org
 help / color / mirror / Atom feed
From: Shuah Khan <shuahkh@osg.samsung.com>
To: mchehab@osg.samsung.com, tiwai@suse.de, perex@perex.cz,
	chehabrafael@gmail.com, hans.verkuil@cisco.com,
	prabhakar.csengg@gmail.com, chris.j.arges@canonical.com
Cc: Shuah Khan <shuahkh@osg.samsung.com>,
	linux-media@vger.kernel.org, alsa-devel@alsa-project.org
Subject: [PATCH MC Next Gen] sound/usb: Fix out of bounds access in media_entity_init()
Date: Fri,  4 Dec 2015 17:00:29 -0700	[thread overview]
Message-ID: <1449273629-4991-1-git-send-email-shuahkh@osg.samsung.com> (raw)

Fix the out of bounds access in media_entity_init() found
by KASan. This is a result of media_mixer_init() failing
to allocate memory for all 3 of its pads before calling
media_entity_init(). Fix it to allocate memory for the
right struct media_mixer_ctl instead of struct media_ctl.

Signed-off-by: Shuah Khan <shuahkh@osg.samsung.com>
---

This patch fixes the mixer patch below:
https://patchwork.linuxtv.org/patch/31827/

 sound/usb/media.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/sound/usb/media.c b/sound/usb/media.c
index bebe27b..0cb44b9 100644
--- a/sound/usb/media.c
+++ b/sound/usb/media.c
@@ -233,8 +233,8 @@ int media_mixer_init(struct snd_usb_audio *chip)
 		if (mixer->media_mixer_ctl)
 			continue;
 
-		/* allocate media_ctl */
-		mctl = kzalloc(sizeof(struct media_ctl), GFP_KERNEL);
+		/* allocate media_mixer_ctl */
+		mctl = kzalloc(sizeof(struct media_mixer_ctl), GFP_KERNEL);
 		if (!mctl)
 			return -ENOMEM;
 
@@ -244,6 +244,7 @@ int media_mixer_init(struct snd_usb_audio *chip)
 		mctl->media_pad[0].flags = MEDIA_PAD_FL_SINK;
 		mctl->media_pad[1].flags = MEDIA_PAD_FL_SOURCE;
 		mctl->media_pad[2].flags = MEDIA_PAD_FL_SOURCE;
+
 		media_entity_init(&mctl->media_entity, MEDIA_MIXER_PAD_MAX,
 				  mctl->media_pad);
 		ret =  media_device_register_entity(mctl->media_dev,
-- 
2.5.0


             reply	other threads:[~2015-12-05  0:00 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-05  0:00 Shuah Khan [this message]
2015-12-07  8:15 ` [alsa-devel] [PATCH MC Next Gen] sound/usb: Fix out of bounds access in media_entity_init() Takashi Iwai
2015-12-07 14:23   ` Shuah Khan

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=1449273629-4991-1-git-send-email-shuahkh@osg.samsung.com \
    --to=shuahkh@osg.samsung.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=chehabrafael@gmail.com \
    --cc=chris.j.arges@canonical.com \
    --cc=hans.verkuil@cisco.com \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@osg.samsung.com \
    --cc=perex@perex.cz \
    --cc=prabhakar.csengg@gmail.com \
    --cc=tiwai@suse.de \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.