]> git.karo-electronics.de Git - karo-tx-linux.git/commit
idr: make idr_destroy() imply idr_remove_all()
authorTejun Heo <tj@kernel.org>
Wed, 20 Feb 2013 02:16:03 +0000 (13:16 +1100)
committerStephen Rothwell <sfr@canb.auug.org.au>
Wed, 20 Feb 2013 05:53:39 +0000 (16:53 +1100)
commit224a5c2d6918f0ba972ffe955343c8c6621758f9
treee02e1899829b6d0b9d441ab92cf65cea64fca139
parent5ae528b6f36ce521ab3fb3a8befb77420d0877ed
idr: make idr_destroy() imply idr_remove_all()

idr is silly in quite a few ways, one of which is how it's supposed to
be destroyed - idr_destroy() doesn't release IDs and doesn't even
whine if the idr isn't empty.  If the caller forgets idr_remove_all(),
it simply leaks memory.

Even ida gets this wrong and leaks memory on destruction.  There is
absoltely no reason not to call idr_remove_all() from idr_destroy().
Nobody is abusing idr_destroy() for shrinking free layer buffer and
continues to use idr after idr_destroy(), so it's safe to do
remove_all from destroy.

In the whole kernel, there is only one place where idr_remove_all() is
legitimiately used without following idr_destroy() while there are
quite a few places where the caller forgets either idr_remove_all() or
idr_destroy() leaking memory.

This patch makes idr_destroy() call idr_destroy_all() and updates the
function description accordingly.

Signed-off-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
lib/idr.c