<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">From: Cheng Renquan &lt;crquan@gmail.com&gt;

The tt_internal's 'use' field is superfluous: the module's refcount can do
the work properly.  An acceptable side-effect is that this increases the
reference counts reported by 'lsmod'.

Remove the superfluous test when removing a target module.

[Crash possible without this on SMP - agk]

Cc: stable@kernel.org
Signed-off-by: Cheng Renquan &lt;crquan@gmail.com&gt;
Signed-off-by: Alasdair G Kergon &lt;agk@redhat.com&gt;
Reviewed-by: Alasdair G Kergon &lt;agk@redhat.com&gt;
Reviewed-by: Jonathan Brassow &lt;jbrassow@redhat.com&gt;
---
 drivers/md/dm-target.c |   20 +++-----------------
 1 files changed, 3 insertions(+), 17 deletions(-)

Index: linux-2.6.29/drivers/md/dm-target.c
===================================================================
--- linux-2.6.29.orig/drivers/md/dm-target.c	2009-04-02 16:34:52.000000000 +0100
+++ linux-2.6.29/drivers/md/dm-target.c	2009-04-02 16:45:23.000000000 +0100
@@ -18,7 +18,6 @@ struct tt_internal {
 	struct target_type tt;
 
 	struct list_head list;
-	long use;
 };
 
 static LIST_HEAD(_targets);
@@ -44,12 +43,8 @@ static struct tt_internal *get_target_ty
 	down_read(&amp;_lock);
 
 	ti = __find_target_type(name);
-	if (ti) {
-		if ((ti-&gt;use == 0) &amp;&amp; !try_module_get(ti-&gt;tt.module))
-			ti = NULL;
-		else
-			ti-&gt;use++;
-	}
+	if (ti &amp;&amp; !try_module_get(ti-&gt;tt.module))
+		ti = NULL;
 
 	up_read(&amp;_lock);
 	return ti;
@@ -77,10 +72,7 @@ void dm_put_target_type(struct target_ty
 	struct tt_internal *ti = (struct tt_internal *) t;
 
 	down_read(&amp;_lock);
-	if (--ti-&gt;use == 0)
-		module_put(ti-&gt;tt.module);
-
-	BUG_ON(ti-&gt;use &lt; 0);
+	module_put(ti-&gt;tt.module);
 	up_read(&amp;_lock);
 
 	return;
@@ -140,12 +132,6 @@ void dm_unregister_target(struct target_
 		BUG();
 	}
 
-	if (ti-&gt;use) {
-		DMCRIT("Attempt to unregister target still in use: %s",
-		       t-&gt;name);
-		BUG();
-	}
-
 	list_del(&amp;ti-&gt;list);
 	kfree(ti);
 
</pre></body></html>