]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/3.0.1/dm-fix-idr-leak-on-module-removal.patch
fixes for 4.19
[thirdparty/kernel/stable-queue.git] / releases / 3.0.1 / dm-fix-idr-leak-on-module-removal.patch
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
5
6 From: Alasdair G Kergon <agk@redhat.com>
7
8 commit d15b774c2920d55e3d58275c97fbe3adc3afde38 upstream.
9
10 Destroy _minor_idr when unloading the core dm module. (Found by kmemleak.)
11
12 Signed-off-by: Alasdair G Kergon <agk@redhat.com>
13 Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
14
15 ---
16 drivers/md/dm.c | 10 ++++++++--
17 1 file changed, 8 insertions(+), 2 deletions(-)
18
19 --- a/drivers/md/dm.c
20 +++ b/drivers/md/dm.c
21 @@ -37,6 +37,8 @@ static const char *_name = DM_NAME;
22 static unsigned int major = 0;
23 static unsigned int _major = 0;
24
25 +static DEFINE_IDR(_minor_idr);
26 +
27 static DEFINE_SPINLOCK(_minor_lock);
28 /*
29 * For bio-based dm.
30 @@ -313,6 +315,12 @@ static void __exit dm_exit(void)
31
32 while (i--)
33 _exits[i]();
34 +
35 + /*
36 + * Should be empty by this point.
37 + */
38 + idr_remove_all(&_minor_idr);
39 + idr_destroy(&_minor_idr);
40 }
41
42 /*
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);
48 -
49 static void free_minor(int minor)
50 {
51 spin_lock(&_minor_lock);