]>
Commit | Line | Data |
---|---|---|
722b7c48 GKH |
1 | From foo@baz Sat Jul 28 10:14:30 CEST 2018 |
2 | From: Christian Gromm <christian.gromm@microchip.com> | |
3 | Date: Tue, 8 May 2018 11:45:06 +0200 | |
4 | Subject: staging: most: cdev: fix chrdev_region leak | |
5 | ||
6 | From: Christian Gromm <christian.gromm@microchip.com> | |
7 | ||
8 | [ Upstream commit aba258b73101670c06b1dd700e500ed0a3fa0e8e ] | |
9 | ||
10 | The function unregister_chrdev_region is called with a different counter | |
11 | as the alloc_chrdev_region. To fix this, this patch introduces the | |
12 | constant CHRDEV_REGION_SIZE that is used in both functions. | |
13 | ||
14 | Signed-off-by: Christian Gromm <christian.gromm@microchip.com> | |
15 | Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> | |
16 | Signed-off-by: Sasha Levin <alexander.levin@microsoft.com> | |
17 | Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> | |
18 | --- | |
19 | drivers/staging/most/cdev/cdev.c | 6 ++++-- | |
20 | 1 file changed, 4 insertions(+), 2 deletions(-) | |
21 | ||
22 | --- a/drivers/staging/most/cdev/cdev.c | |
23 | +++ b/drivers/staging/most/cdev/cdev.c | |
24 | @@ -18,6 +18,8 @@ | |
25 | #include <linux/idr.h> | |
26 | #include "most/core.h" | |
27 | ||
28 | +#define CHRDEV_REGION_SIZE 50 | |
29 | + | |
30 | static struct cdev_component { | |
31 | dev_t devno; | |
32 | struct ida minor_id; | |
33 | @@ -513,7 +515,7 @@ static int __init mod_init(void) | |
34 | spin_lock_init(&ch_list_lock); | |
35 | ida_init(&comp.minor_id); | |
36 | ||
37 | - err = alloc_chrdev_region(&comp.devno, 0, 50, "cdev"); | |
38 | + err = alloc_chrdev_region(&comp.devno, 0, CHRDEV_REGION_SIZE, "cdev"); | |
39 | if (err < 0) | |
40 | goto dest_ida; | |
41 | comp.major = MAJOR(comp.devno); | |
42 | @@ -523,7 +525,7 @@ static int __init mod_init(void) | |
43 | return 0; | |
44 | ||
45 | free_cdev: | |
46 | - unregister_chrdev_region(comp.devno, 1); | |
47 | + unregister_chrdev_region(comp.devno, CHRDEV_REGION_SIZE); | |
48 | dest_ida: | |
49 | ida_destroy(&comp.minor_id); | |
50 | class_destroy(comp.class); |