From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753984Ab0EGHRm (ORCPT ); Fri, 7 May 2010 03:17:42 -0400 Received: from mail-pz0-f204.google.com ([209.85.222.204]:52964 "EHLO mail-pz0-f204.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752713Ab0EGHRl (ORCPT ); Fri, 7 May 2010 03:17:41 -0400 DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; b=F/gOE45xd+RK6mp0R1CTS/N8ovcXb8YOmWFdtM5VtEYZSsoyfRs/seLTBnnMcXAuiT 0FFI32Bi972u97whQW9ZIZsZu7hQTtFiv8+DGOFp6/uGuGSnnQ7U0xj7prnCjEV8dzHF 4W7xYaTwD6cqRtKTk64jWgk6APyuO5vXDexto= MIME-Version: 1.0 In-Reply-To: References: Date: Fri, 7 May 2010 15:17:39 +0800 Message-ID: Subject: Re: [PATCH] Check kmalloc return value before use the buffer From: Steven Liu To: Linus WALLEIJ Cc: "linux-kernel@vger.kernel.org" Content-Type: text/plain; charset=ISO-8859-1 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Signed-off-by: LiuQi --- arch/arm/mach-u300/dummyspichip.c | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-) diff --git a/arch/arm/mach-u300/dummyspichip.c b/arch/arm/mach-u300/dummyspichip.c index 5f55012..df19f9b 100644 --- a/arch/arm/mach-u300/dummyspichip.c +++ b/arch/arm/mach-u300/dummyspichip.c @@ -64,6 +64,11 @@ static ssize_t dummy_looptest(struct device *dev, goto out; } bigrxbuf_virtual = kmalloc(DMA_TEST_SIZE, GFP_KERNEL); + if (bigrxbuf_virtual == NULL) { + status = -ENOMEM; + kfree(bigtxbuf_virtual); + goto out; + } /* Fill TXBUF with some happy pattern */ memset(bigtxbuf_virtual, 0xAA, DMA_TEST_SIZE); -- 1.6.0.3