aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/md/dm-target.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/md/dm-target.c')
-rw-r--r--drivers/md/dm-target.c20
1 files changed, 3 insertions, 17 deletions
diff --git a/drivers/md/dm-target.c b/drivers/md/dm-target.c
index 7decf10006e4..db72c9497bb4 100644
--- a/drivers/md/dm-target.c
+++ b/drivers/md/dm-target.c
@@ -18,7 +18,6 @@ struct tt_internal {
18 struct target_type tt; 18 struct target_type tt;
19 19
20 struct list_head list; 20 struct list_head list;
21 long use;
22}; 21};
23 22
24static LIST_HEAD(_targets); 23static LIST_HEAD(_targets);
@@ -44,12 +43,8 @@ static struct tt_internal *get_target_type(const char *name)
44 down_read(&_lock); 43 down_read(&_lock);
45 44
46 ti = __find_target_type(name); 45 ti = __find_target_type(name);
47 if (ti) { 46 if (ti && !try_module_get(ti->tt.module))
48 if ((ti->use == 0) && !try_module_get(ti->tt.module)) 47 ti = NULL;
49 ti = NULL;
50 else
51 ti->use++;
52 }
53 48
54 up_read(&_lock); 49 up_read(&_lock);
55 return ti; 50 return ti;
@@ -77,10 +72,7 @@ void dm_put_target_type(struct target_type *t)
77 struct tt_internal *ti = (struct tt_internal *) t; 72 struct tt_internal *ti = (struct tt_internal *) t;
78 73
79 down_read(&_lock); 74 down_read(&_lock);
80 if (--ti->use == 0) 75 module_put(ti->tt.module);
81 module_put(ti->tt.module);
82
83 BUG_ON(ti->use < 0);
84 up_read(&_lock); 76 up_read(&_lock);
85 77
86 return; 78 return;
@@ -140,12 +132,6 @@ void dm_unregister_target(struct target_type *t)
140 BUG(); 132 BUG();
141 } 133 }
142 134
143 if (ti->use) {
144 DMCRIT("Attempt to unregister target still in use: %s",
145 t->name);
146 BUG();
147 }
148
149 list_del(&ti->list); 135 list_del(&ti->list);
150 kfree(ti); 136 kfree(ti);
151 137