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:	Tue, 5 May 2015 14:42:29 -0500
From:	Scott Wood <scottwood@...escale.com>
To:	Rivera Jose-B46482 <German.Rivera@...escale.com>
CC:	Dan Carpenter <dan.carpenter@...cle.com>,
	"devel@...verdev.osuosl.org" <devel@...verdev.osuosl.org>,
	"agraf@...e.de" <agraf@...e.de>, "arnd@...db.de" <arnd@...db.de>,
	Sharma Bhupesh-B45370 <bhupesh.sharma@...escale.com>,
	"gregkh@...uxfoundation.org" <gregkh@...uxfoundation.org>,
	"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
	Yoder Stuart-B08248 <stuart.yoder@...escale.com>,
	Erez Nir-RM30794 <nir.erez@...escale.com>,
	"katz Itai-RM05202" <itai.katz@...escale.com>,
	Hamciuc Bogdan-BHAMCIU1 <bhamciu1@...escale.com>,
	Marginean Alexandru-R89243 <R89243@...escale.com>,
	Schmitt Richard-B43082 <richard.schmitt@...escale.com>
Subject: Re: [PATCH 1/7] staging: fsl-mc: MC bus IRQ support

On Tue, 2015-05-05 at 11:08 -0500, Rivera Jose-B46482 wrote:
> > > > to read what "goto error;" does.  The error handling here calls
> > > > devm_kfree() which is not needed...  devm_ functions automatically
> > > > clean up after themselves.  This seems a pattern throughout.  Do a
> > > > search for
> > > > devm_free() and see which ones are really needed or not.
> > > >
> > > I know that memory allocated with devm_kzalloc() is freed at the end
> > > of the lifetime of the device it is attached to. However, in error
> > > paths, why wait until the device is destroyed? Why not free the memory
> > > earlier so that it can be used for other purposes?
> > 
> Why then do the devm_kfree() function exist?
> 
> I will not remove the devm_free() calls unless the upstream maintainer
> requires me to do so.

The whole point of devm is to simplify (often poorly tested) error
paths.  You're trying to optimize the error path instead of simplify it,
which doesn't make sense.

devm_kfree() is for the uncommon case when you want to free the memory
in a situation where the device isn't being unbound any time soon, but
you still want the memory to be handled by devm for some reason.

Most users of devm_kzalloc() do not use devm_kfree():
scott@...tra:~/fsl/git/linux/upstream$ git grep devm_kzalloc|wc -l
2750
scott@...tra:~/fsl/git/linux/upstream$ git grep devm_kfree|wc -l
118

-Scott


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