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: <20141118171628.GA434@htj.dyndns.org>
Date:	Tue, 18 Nov 2014 12:16:28 -0500
From:	Tejun Heo <tj@...nel.org>
To:	Azat Khuzhin <a3at.mail@...il.com>
Cc:	Jens Axboe <axboe@...nel.dk>,
	Alexander Viro <viro@...iv.linux.org.uk>,
	Christoph Hellwig <hch@...radead.org>,
	linux-fsdevel@...r.kernel.org, linux-kernel@...r.kernel.org,
	Andrew Morton <akpm@...ux-foundation.org>
Subject: Re: [PATCH vfs 1/2] lib: implement ptrset

Hello,

On Tue, Nov 18, 2014 at 06:56:29PM +0300, Azat Khuzhin wrote:
> On Thu, Nov 13, 2014 at 05:09:27PM -0500, Tejun Heo wrote:
> > +int ptrset_add(void *ptr, struct ptrset *set, gfp_t gfp)
> > +{
> > +	struct ptrset_elem *elem;
> > +	struct rb_node *parent, **slot;
> > +
> > +	elem = kmalloc(sizeof(*elem), gfp);
> > +	if (!elem && !in_interrupt())	/* see ptrset_preload() */
> > +		elem = this_cpu_xchg(ptrset_preload_elem, NULL);
> > +	if (!elem)
> > +		return -ENOMEM;
> > +	elem->ptr = ptr;
> > +
> > +	if (ptrset_find_slot(elem->ptr, set, &slot, &parent)) {
> > +		kfree(elem);
> > +		return -EEXIST;
> > +	}
> 
> Maybe allocation *after* ptrset_find_slot() will be better?
> This will avoid extra kmalloc/kfree if such ptr already exist (and also
> will avoid ENOMEM for such cases).

Sure thing.  Will post an updated version soon.

Thanks.

-- 
tejun
--
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