From: Rusty Russell <rusty@rustcorp.com.au>

loop.c has one of those places where maniping own refcounts is safe: to get
into the ioctl handler you need to have the device open, so that holds a
refcount already (verified that this actually happens).

The compile warning is irritating.



 drivers/block/loop.c |    9 ++++++---
 1 files changed, 6 insertions(+), 3 deletions(-)

diff -puN drivers/block/loop.c~loop-warning-fix drivers/block/loop.c
--- 25/drivers/block/loop.c~loop-warning-fix	2003-05-13 00:51:28.000000000 -0700
+++ 25-akpm/drivers/block/loop.c	2003-05-13 00:51:28.000000000 -0700
@@ -651,7 +651,8 @@ static int loop_set_fd(struct loop_devic
 	int		lo_flags = 0;
 	int		error;
 
-	MOD_INC_USE_COUNT;
+	/* This is safe, since we have a reference from open(). */
+	__module_get(THIS_MODULE);
 
 	error = -EBUSY;
 	if (lo->lo_state != Lo_unbound)
@@ -751,7 +752,8 @@ static int loop_set_fd(struct loop_devic
  out_putf:
 	fput(file);
  out:
-	MOD_DEC_USE_COUNT;
+	/* This is safe: open() is still holding a reference. */
+	module_put(THIS_MODULE);
 	return error;
 }
 
@@ -824,7 +826,8 @@ static int loop_clr_fd(struct loop_devic
 	filp->f_dentry->d_inode->i_mapping->gfp_mask = gfp;
 	lo->lo_state = Lo_unbound;
 	fput(filp);
-	MOD_DEC_USE_COUNT;
+	/* This is safe: open() is still holding a reference. */
+	module_put(THIS_MODULE);
 	return 0;
 }
 

_