[PATCH 08/08] dm: fix ordering of initialization in alloc_dev()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



 In alloc_dev(), we register the device with the block layer and then
 continue to initialize the device. register_disk() will have already
 made the device available to userspace, and a potential race exists
 with the device being opened for use and the completion of the
 initialization.

 This patch moves the final bits of the initialization above the disk
 registration.

Signed-off-by: Jeff Mahoney <[email protected]>
--
 drivers/md/dm.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diff -ruNpX ../dontdiff linux-2.6.16-staging1/drivers/md/dm.c linux-2.6.16-staging2/drivers/md/dm.c
--- linux-2.6.16-staging1/drivers/md/dm.c	2006-04-13 16:18:24.000000000 -0400
+++ linux-2.6.16-staging2/drivers/md/dm.c	2006-04-13 16:18:24.000000000 -0400
@@ -837,6 +837,10 @@ static struct mapped_device *alloc_dev(u
 	if (!md->disk)
 		goto bad4;
 
+	atomic_set(&md->pending, 0);
+	init_waitqueue_head(&md->wait);
+	init_waitqueue_head(&md->eventq);
+
 	md->disk->major = _major;
 	md->disk->first_minor = minor;
 	md->disk->fops = &dm_blk_dops;
@@ -845,10 +849,6 @@ static struct mapped_device *alloc_dev(u
 	sprintf(md->disk->disk_name, "dm-%d", minor);
 	add_disk(md->disk);
 
-	atomic_set(&md->pending, 0);
-	init_waitqueue_head(&md->wait);
-	init_waitqueue_head(&md->eventq);
-
 	/* Populate the mapping, nobody knows we exist yet */
 	spin_lock(&_minor_lock);
 	r = idr_replace(&_minor_idr, md, minor);
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux