lkml.org 
[lkml]   [2010]   [May]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRE: [PATCH] Check kmalloc return value before use the buffer
Hi Liu,

> Hi,linus.walleij
>
> Check kmalloc return value before use the buffer
>
>
> Signed-off-by: LiuQi <lingjiujianke@gmail.com>
> ---
> 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 962f9de..4f2af7c 100644
> --- a/arch/arm/mach-u300/dummyspichip.c
> +++ b/arch/arm/mach-u300/dummyspichip.c
> @@ -63,6 +63,11 @@ static ssize_t dummy_looptest(struct device *dev,
> goto out;
> }
> bigrxbuf_virtual = kmalloc(DMA_TEST_SIZE, GFP_KERNEL);
> + if (bigtxbuf_virtual == NULL) {
> + status = -ENOMEM;
> + kfree(bigtxbuf_virtual);

kfree():ing NULL is OK, but you just checked it to be NULL so why?

> + goto out;
> + }
>
> /* Fill TXBUF with some happy pattern */
> memset(bigtxbuf_virtual, 0xAA, DMA_TEST_SIZE);

Otherwise the bug it fixes is good to fix.

Yours,
Linus Walleij


\
 
 \ /
  Last update: 2010-05-07 08:55    [W:0.055 / U:0.372 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site