From: Alasdair G Kergon Date: Tue, 2 Aug 2011 11:32:01 +0000 (+0100) Subject: dm: fix idr leak on module removal X-Git-Tag: v2.6.33.17~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8d637efc631096456dba6ae73d5fdc5eecd2906d;p=thirdparty%2Fkernel%2Fstable.git dm: fix idr leak on module removal commit d15b774c2920d55e3d58275c97fbe3adc3afde38 upstream. Destroy _minor_idr when unloading the core dm module. (Found by kmemleak.) Signed-off-by: Alasdair G Kergon Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/md/dm.c b/drivers/md/dm.c index 2e41d5ee7cc81..99f0602797dfb 100644 --- a/drivers/md/dm.c +++ b/drivers/md/dm.c @@ -36,6 +36,8 @@ static const char *_name = DM_NAME; static unsigned int major = 0; static unsigned int _major = 0; +static DEFINE_IDR(_minor_idr); + static DEFINE_SPINLOCK(_minor_lock); /* * For bio-based dm. @@ -324,6 +326,12 @@ static void __exit dm_exit(void) while (i--) _exits[i](); + + /* + * Should be empty by this point. + */ + idr_remove_all(&_minor_idr); + idr_destroy(&_minor_idr); } /* @@ -1772,8 +1780,6 @@ static int dm_any_congested(void *congested_data, int bdi_bits) /*----------------------------------------------------------------- * An IDR is used to keep track of allocated minor numbers. *---------------------------------------------------------------*/ -static DEFINE_IDR(_minor_idr); - static void free_minor(int minor) { spin_lock(&_minor_lock);