From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756808Ab0KAJjR (ORCPT ); Mon, 1 Nov 2010 05:39:17 -0400 Received: from cantor.suse.de ([195.135.220.2]:51856 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751567Ab0KAJjP (ORCPT ); Mon, 1 Nov 2010 05:39:15 -0400 Date: Mon, 01 Nov 2010 10:39:14 +0100 Message-ID: From: Takashi Iwai To: Jesper Juhl Cc: linux-kernel@vger.kernel.org, Jaroslav Kysela Subject: Re: [PATCH] USB PCM Sound driver neglects kmalloc return value check and may deref NULL. In-Reply-To: References: User-Agent: Wanderlust/2.15.6 (Almost Unreal) SEMI/1.14.6 (Maruoka) FLIM/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL/10.7 Emacs/23.1 (x86_64-suse-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 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 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 >