Messages in this thread Patch in this message | ![/](/images/icornerl.gif) | | From | Angus Sawyer <> | Subject | [PATCH] loop driver kernel thread module reference fix | Date | Wed, 17 Sep 2003 16:28:53 +0100 |
| |
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; } _
- 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/
| ![\](/images/icornerr.gif) |