lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20100510214946.GA4361@hexapodia.org>
Date:	Mon, 10 May 2010 14:49:46 -0700
From:	Andy Isaacson <adi@...apodia.org>
To:	Steven Liu <lingjiujianke@...il.com>,
	Nigel Cunningham <nigel@...onice.net>
Cc:	Linus WALLEIJ <linus.walleij@...ricsson.com>,
	"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] Check kmalloc return value before use the buffer

On Fri, May 07, 2010 at 03:17:39PM +0800, Steven Liu wrote:
>  	bigrxbuf_virtual = kmalloc(DMA_TEST_SIZE, GFP_KERNEL);
> +	if (bigrxbuf_virtual == NULL) {
> +		status = -ENOMEM;
> +		kfree(bigtxbuf_virtual);
> +		goto out;
> +	}

On Sat, May 08, 2010 at 11:27:09AM +1000, Nigel Cunningham wrote:
>> Acked-by: Linus Walleij<linus.walleij@...ricsson.com>
>
> Acked-by: Nigel Cunningham <nigel@...onice.net>

NACK.  Don't duplicate kfree(), instead do something like

--- a/arch/arm/mach-u300/dummyspichip.c
+++ b/arch/arm/mach-u300/dummyspichip.c
@@ -58,12 +58,13 @@ static ssize_t dummy_looptest(struct device *dev,
        if (mutex_lock_interruptible(&p_dummy->lock))
                return -ERESTARTSYS;
 
+       status = -ENOMEM;
        bigtxbuf_virtual = kmalloc(DMA_TEST_SIZE, GFP_KERNEL);
-       if (bigtxbuf_virtual == NULL) {
-               status = -ENOMEM;
+       if (bigtxbuf_virtual == NULL)
                goto out;
-       }
        bigrxbuf_virtual = kmalloc(DMA_TEST_SIZE, GFP_KERNEL);
+       if (bigrxbuf_virtual == NULL)
+               goto out_free_tx;
 
        /* Fill TXBUF with some happy pattern */
        memset(bigtxbuf_virtual, 0xAA, DMA_TEST_SIZE);
@@ -215,6 +216,7 @@ static ssize_t dummy_looptest(struct device *dev,
 
        status = sprintf(buf, "loop test complete\n");
        kfree(bigrxbuf_virtual);
+ out_free_tx:
        kfree(bigtxbuf_virtual);
  out:
        mutex_unlock(&p_dummy->lock);

-andy
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ