]> git.neil.brown.name Git - history.git/commitdiff
[PATCH] dm: Correct target_type reference counting
authorJoe Thornber <joe@fib011235813.fsnet.co.uk>
Wed, 8 Jan 2003 01:54:02 +0000 (17:54 -0800)
committerTrond Myklebust <trond.myklebust@fys.uio.no>
Wed, 8 Jan 2003 01:54:02 +0000 (17:54 -0800)
ti->use was only getting incremented the first time a target type was
retrieved (bug introduced by recent hch patch).

drivers/md/dm-target.c

index 886302cbd2b1f3835c146743d95a7cf8c0c3b8dd..4fb36b866f3d61e2de8112429783098118b3929f 100644 (file)
@@ -43,15 +43,16 @@ static struct tt_internal *get_target_type(const char *name)
        struct tt_internal *ti;
 
        read_lock(&_lock);
+
        ti = __find_target_type(name);
-       if (ti && ti->use == 0) {
-               if (try_module_get(ti->tt.module))
-                       ti->use++;
-               else
+       if (ti) {
+               if ((ti->use == 0) && !try_module_get(ti->tt.module))
                        ti = NULL;
+               else
+                       ti->use++;
        }
-       read_unlock(&_lock);
 
+       read_unlock(&_lock);
        return ti;
 }