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>
This commit is contained in:
Родитель
bb91bc7bac
Коммит
d15b774c29
|
@ -37,6 +37,8 @@ static const char *_name = DM_NAME;
|
||||||
static unsigned int major = 0;
|
static unsigned int major = 0;
|
||||||
static unsigned int _major = 0;
|
static unsigned int _major = 0;
|
||||||
|
|
||||||
|
static DEFINE_IDR(_minor_idr);
|
||||||
|
|
||||||
static DEFINE_SPINLOCK(_minor_lock);
|
static DEFINE_SPINLOCK(_minor_lock);
|
||||||
/*
|
/*
|
||||||
* For bio-based dm.
|
* For bio-based dm.
|
||||||
|
@ -313,6 +315,12 @@ static void __exit dm_exit(void)
|
||||||
|
|
||||||
while (i--)
|
while (i--)
|
||||||
_exits[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.
|
* An IDR is used to keep track of allocated minor numbers.
|
||||||
*---------------------------------------------------------------*/
|
*---------------------------------------------------------------*/
|
||||||
static DEFINE_IDR(_minor_idr);
|
|
||||||
|
|
||||||
static void free_minor(int minor)
|
static void free_minor(int minor)
|
||||||
{
|
{
|
||||||
spin_lock(&_minor_lock);
|
spin_lock(&_minor_lock);
|
||||||
|
|
Загрузка…
Ссылка в новой задаче