summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlasdair G Kergon <agk@redhat.com>2011-08-02 12:32:01 +0100
committerAlasdair G Kergon <agk@redhat.com>2011-08-02 12:32:01 +0100
commitd15b774c2920d55e3d58275c97fbe3adc3afde38 (patch)
tree4801d4e5a70f1e8e57475e6ea2f8e1238b6bbc75
parentbb91bc7bacb906c9f3a9b22744c53fa7564b51ba (diff)
downloadop-kernel-dev-d15b774c2920d55e3d58275c97fbe3adc3afde38.zip
op-kernel-dev-d15b774c2920d55e3d58275c97fbe3adc3afde38.tar.gz
dm: fix idr leak on module removal
Destroy _minor_idr when unloading the core dm module. (Found by kmemleak.) Cc: stable@kernel.org Signed-off-by: Alasdair G Kergon <agk@redhat.com>
-rw-r--r--drivers/md/dm.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/drivers/md/dm.c b/drivers/md/dm.c
index 0cf68b4..41abc6d 100644
--- a/drivers/md/dm.c
+++ b/drivers/md/dm.c
@@ -37,6 +37,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.
@@ -313,6 +315,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);
}
/*
@@ -1705,8 +1713,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);
OpenPOWER on IntegriCloud