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]
Date:	Mon, 19 Mar 2007 14:10:38 -0700
From:	Andrew Morton <akpm@...ux-foundation.org>
To:	Matt Mackall <mpm@...enic.com>
Cc:	Christoph Lameter <clameter@....com>,
	Pekka J Enberg <penberg@...helsinki.fi>, ast@...dv.de,
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH] slab: deal with NULL pointers passed to kmem_cache_free

On Mon, 19 Mar 2007 15:49:46 -0500
Matt Mackall <mpm@...enic.com> wrote:

> On Mon, Mar 19, 2007 at 10:08:03AM -0700, Christoph Lameter wrote:
> > On Mon, 19 Mar 2007, Pekka J Enberg wrote:
> > 
> > > This changes kmem_cache_free() to deal with NULL objects passed to it. The 
> > > current behavior is inconsistent with kfree() so there are callers 
> > > passing NULL to kmem_cache_free().
> > 
> > Hmmm.. kmem_cache_free is significantly different. One also needs to 
> > specify the slab cache.
> 
> I think this sort of thing should work:
> 
> a = kmalloc(...)
> b = kmem_cache_alloc(..)
> c = allocate_some_id(...)
> if (!a || !b || !c) {
>    free_some_id(c)
>    kmem_cache_free(c)
>    kfree(a);
>    return -ENOMEM;
> }

Would prefer to do:

static inline void kmem_cache_free_if_not_null(struct kmem_cache *cachep,
						void *objp)
{
	if (objp)
		kmem_cache_free(cachep, objp);
}

so that we don't add extra overhead to all the thousands of existing,
well-behaved callsites.

-
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