From: Takashi Iwai <tiwai@suse.de>
To: Jesper Juhl <jj@chaosbits.net>
Cc: linux-kernel@vger.kernel.org, Jaroslav Kysela <perex@perex.cz>
Subject: Re: [PATCH] USB PCM Sound driver neglects kmalloc return value check and may deref NULL.
Date: Mon, 01 Nov 2010 10:39:14 +0100 [thread overview]
Message-ID: <s5h1v752xj1.wl%tiwai@suse.de> (raw)
In-Reply-To: <alpine.LNX.2.00.1010292032550.24561@swampdragon.chaosbits.net>
At Fri, 29 Oct 2010 20:40:23 +0200 (CEST),
Jesper Juhl wrote:
>
>
> sound/usb/pcm.c::snd_usb_pcm_check_knot() fails to check the return value
> from kmalloc() and may end up dereferencing a null pointer.
> The patch below (compile tested only) should take care of that little
> problem.
>
>
> Signed-off-by: Jesper Juhl <jj@chaosbits.net>
Applied now. Thanks!
Takashi
> ---
> pcm.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/sound/usb/pcm.c b/sound/usb/pcm.c
> index cff3a3c..4132522 100644
> --- a/sound/usb/pcm.c
> +++ b/sound/usb/pcm.c
> @@ -676,8 +676,10 @@ static int snd_usb_pcm_check_knot(struct snd_pcm_runtime *runtime,
> if (!needs_knot)
> return 0;
>
> - subs->rate_list.count = count;
> subs->rate_list.list = kmalloc(sizeof(int) * count, GFP_KERNEL);
> + if (!subs->rate_list.list)
> + return -ENOMEM;
> + subs->rate_list.count = count;
> subs->rate_list.mask = 0;
> count = 0;
> list_for_each_entry(fp, &subs->fmt_list, list) {
>
>
> --
> Jesper Juhl <jj@chaosbits.net> http://www.chaosbits.net/
> Plain text mails only, please http://www.expita.com/nomime.html
> Don't top-post http://www.catb.org/~esr/jargon/html/T/top-post.html
>
prev parent reply other threads:[~2010-11-01 9:39 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-10-29 18:40 Jesper Juhl
2010-11-01 9:39 ` 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=s5h1v752xj1.wl%tiwai@suse.de \
--to=tiwai@suse.de \
--cc=jj@chaosbits.net \
--cc=linux-kernel@vger.kernel.org \
--cc=perex@perex.cz \
/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
all inboxes | Powered by JetHome®