mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Angus Sawyer <angus.sawyer@dsl.pipex.com>
To: linux-kernel@vger.kernel.org
Subject: [PATCH] loop driver kernel thread module reference fix
Date: Wed, 17 Sep 2003 16:28:53 +0100	[thread overview]
Message-ID: <200309171628.55240.angus.sawyer@dsl.pipex.com> (raw)


the loop driver does not hold module references for the kernel_thread, and 
does not appear to wait for thread termination at any point.  

This patch associates the ref counting with the kernel thread which covers
the existing set/clear fd interval.

Hope this is OK.

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

diff -puN drivers/block/loop.c~loop drivers/block/loop.c
--- linux-2.6.0-test5/drivers/block/loop.c~loop	2003-09-17 16:16:19.447291752 
+0100
+++ linux-2.6.0-test5-angus/drivers/block/loop.c	2003-09-17 16:25:55.103778664 
+0100
@@ -651,7 +651,7 @@ static int loop_thread(void *data)
 	}
 
 	up(&lo->lo_sem);
-	return 0;
+	module_put_and_exit(0);
 }
 
 static int loop_set_fd(struct loop_device *lo, struct file *lo_file,
@@ -664,9 +664,6 @@ static int loop_set_fd(struct loop_devic
 	int		lo_flags = 0;
 	int		error;
 
-	/* This is safe, since we have a reference from open(). */
-	__module_get(THIS_MODULE);
-
 	error = -EBUSY;
 	if (lo->lo_state != Lo_unbound)
 		goto out;
@@ -757,6 +754,8 @@ static int loop_set_fd(struct loop_devic
 		blk_queue_merge_bvec(lo->lo_queue, q->merge_bvec_fn);
 	}
 
+	/* This is safe, since we have a reference from open(). */
+	__module_get(THIS_MODULE);
 	kernel_thread(loop_thread, lo, CLONE_FS | CLONE_FILES | CLONE_SIGHAND);
 	down(&lo->lo_sem);
 
@@ -767,7 +766,6 @@ static int loop_set_fd(struct loop_devic
 	fput(file);
  out:
 	/* This is safe: open() is still holding a reference. */
-	module_put(THIS_MODULE);
 	return error;
 }
 
@@ -849,8 +847,6 @@ static int loop_clr_fd(struct loop_devic
 	mapping_set_gfp_mask(filp->f_dentry->d_inode->i_mapping, gfp);
 	lo->lo_state = Lo_unbound;
 	fput(filp);
-	/* This is safe: open() is still holding a reference. */
-	module_put(THIS_MODULE);
 	return 0;
 }
 

_


                 reply	other threads:[~2003-09-17 15:36 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200309171628.55240.angus.sawyer@dsl.pipex.com \
    --to=angus.sawyer@dsl.pipex.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®