1 From d15b774c2920d55e3d58275c97fbe3adc3afde38 Mon Sep 17 00:00:00 2001
2 From: Alasdair G Kergon <agk@redhat.com>
3 Date: Tue, 2 Aug 2011 12:32:01 +0100
4 Subject: dm: fix idr leak on module removal
6 From: Alasdair G Kergon <agk@redhat.com>
8 commit d15b774c2920d55e3d58275c97fbe3adc3afde38 upstream.
10 Destroy _minor_idr when unloading the core dm module. (Found by kmemleak.)
12 Signed-off-by: Alasdair G Kergon <agk@redhat.com>
13 Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
16 drivers/md/dm.c | 10 ++++++++--
17 1 file changed, 8 insertions(+), 2 deletions(-)
21 @@ -37,6 +37,8 @@ static const char *_name = DM_NAME;
22 static unsigned int major = 0;
23 static unsigned int _major = 0;
25 +static DEFINE_IDR(_minor_idr);
27 static DEFINE_SPINLOCK(_minor_lock);
30 @@ -313,6 +315,12 @@ static void __exit dm_exit(void)
36 + * Should be empty by this point.
38 + idr_remove_all(&_minor_idr);
39 + idr_destroy(&_minor_idr);
43 @@ -1705,8 +1713,6 @@ static int dm_any_congested(void *conges
44 /*-----------------------------------------------------------------
45 * An IDR is used to keep track of allocated minor numbers.
46 *---------------------------------------------------------------*/
47 -static DEFINE_IDR(_minor_idr);
49 static void free_minor(int minor)
51 spin_lock(&_minor_lock);