diff options
| author | Alasdair G Kergon <agk@redhat.com> | 2011-08-02 07:32:01 -0400 |
|---|---|---|
| committer | Alasdair G Kergon <agk@redhat.com> | 2011-08-02 07:32:01 -0400 |
| commit | d15b774c2920d55e3d58275c97fbe3adc3afde38 (patch) | |
| tree | 4801d4e5a70f1e8e57475e6ea2f8e1238b6bbc75 | |
| parent | bb91bc7bacb906c9f3a9b22744c53fa7564b51ba (diff) | |
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.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/drivers/md/dm.c b/drivers/md/dm.c index 0cf68b47887..41abc6dd481 100644 --- a/drivers/md/dm.c +++ b/drivers/md/dm.c | |||
| @@ -37,6 +37,8 @@ static const char *_name = DM_NAME; | |||
| 37 | static unsigned int major = 0; | 37 | static unsigned int major = 0; |
| 38 | static unsigned int _major = 0; | 38 | static unsigned int _major = 0; |
| 39 | 39 | ||
| 40 | static DEFINE_IDR(_minor_idr); | ||
| 41 | |||
| 40 | static DEFINE_SPINLOCK(_minor_lock); | 42 | static DEFINE_SPINLOCK(_minor_lock); |
| 41 | /* | 43 | /* |
| 42 | * For bio-based dm. | 44 | * For bio-based dm. |
| @@ -313,6 +315,12 @@ static void __exit dm_exit(void) | |||
| 313 | 315 | ||
| 314 | while (i--) | 316 | while (i--) |
| 315 | _exits[i](); | 317 | _exits[i](); |
| 318 | |||
| 319 | /* | ||
| 320 | * Should be empty by this point. | ||
| 321 | */ | ||
| 322 | idr_remove_all(&_minor_idr); | ||
| 323 | idr_destroy(&_minor_idr); | ||
| 316 | } | 324 | } |
| 317 | 325 | ||
| 318 | /* | 326 | /* |
| @@ -1705,8 +1713,6 @@ static int dm_any_congested(void *congested_data, int bdi_bits) | |||
| 1705 | /*----------------------------------------------------------------- | 1713 | /*----------------------------------------------------------------- |
| 1706 | * An IDR is used to keep track of allocated minor numbers. | 1714 | * An IDR is used to keep track of allocated minor numbers. |
| 1707 | *---------------------------------------------------------------*/ | 1715 | *---------------------------------------------------------------*/ |
| 1708 | static DEFINE_IDR(_minor_idr); | ||
| 1709 | |||
| 1710 | static void free_minor(int minor) | 1716 | static void free_minor(int minor) |
| 1711 | { | 1717 | { |
| 1712 | spin_lock(&_minor_lock); | 1718 | spin_lock(&_minor_lock); |
