Skip to content

Commit

Permalink
dm: fix idr leak on module removal
Browse files Browse the repository at this point in the history
commit d15b774 upstream.

Destroy _minor_idr when unloading the core dm module.  (Found by kmemleak.)

Signed-off-by: Alasdair G Kergon <agk@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
  • Loading branch information
Alasdair G Kergon authored and Greg Kroah-Hartman committed Aug 5, 2011
1 parent eb81cf1 commit c2b4988
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions drivers/md/dm.c
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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);
}

/*
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit c2b4988

Please sign in to comment.