module usage counting in mtdblock

Simon Evans spse at secret.org.uk
Fri Jun 7 09:39:00 EDT 2002


Hi,

I think there is a bug in mtdblock where the open() leaves the module count
1 more than it should be and it should be using BLK_{INC,DEC}_USE_COUNT
everywhere instead of MOD_{INC,DEC}_USE_COUNT

(BLK_{INC,DEC}_USE_COUNT are nops on >= 2.4.14 due to module counting being
done by fs/block_dev.c)

Does the following look correct?

cheers
si


Index: mtdblock.c
===================================================================
RCS file: /home/cvs/mtd/drivers/mtd/mtdblock.c,v
retrieving revision 1.54
diff -u -r1.54 mtdblock.c
--- mtdblock.c	3 May 2002 16:46:24 -0000	1.54
+++ mtdblock.c	7 Jun 2002 13:26:01 -0000
@@ -280,11 +280,13 @@
 	if (dev >= MAX_MTD_DEVICES)
 		return -EINVAL;
 
-	MOD_INC_USE_COUNT;
+	BLK_INC_USE_COUNT;
 
 	mtd = get_mtd_device(NULL, dev);
-	if (!mtd)
+	if (!mtd) {
+		BLK_DEC_USE_COUNT;
 		return -ENODEV;
+	}
 	if (MTD_ABSENT == mtd->type) {
 		put_mtd_device(mtd);
 		BLK_DEC_USE_COUNT;
@@ -326,7 +328,7 @@
 		if (!mtdblk->cache_data) {
 			put_mtd_device(mtdblk->mtd);
 			kfree(mtdblk);
-			MOD_DEC_USE_COUNT;
+			BLK_DEC_USE_COUNT;
 			return -ENOMEM;
 		}
 	}





More information about the linux-mtd mailing list