[PATCH 3/10] dm: Correct target_type reference counting

From: Joe Thornber (joe@fib011235813.fsnet.co.uk)
Date: Wed Jan 08 2003 - 04:55:44 EST


ti->use was only getting incremented the first time a target type was
retrieved (bug introduced by recent hch patch).
--- diff/drivers/md/dm-target.c 2003-01-02 10:43:06.000000000 +0000
+++ source/drivers/md/dm-target.c 2003-01-02 11:16:16.000000000 +0000
@@ -43,15 +43,16 @@
         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;
 }
 
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Wed Jan 15 2003 - 22:00:22 EST