aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/md/md.c
diff options
context:
space:
mode:
authorNeil Brown <neilb@notabene.brown>2008-06-27 18:31:26 -0400
committerNeil Brown <neilb@notabene.brown>2008-06-27 18:31:26 -0400
commitf48ed538386cb41559282d989354e8f5d442d71c (patch)
tree3faa24718c098f19b7e331eae0ba29f145e902da /drivers/md/md.c
parent5e96ee65c8bd629ce093da67a066d3946468298a (diff)
Close race in md_probe
There is a possible race in md_probe. If two threads call md_probe for the same device, then one could exit (having checked that ->gendisk exists) before the other has called kobject_init_and_add, thus returning an incomplete kobj which will cause problems when we try to add children to it. So extend the range of protection of disks_mutex slightly to avoid this possibility. Signed-off-by: Neil Brown <neilb@suse.de>
Diffstat (limited to 'drivers/md/md.c')
-rw-r--r--drivers/md/md.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/md/md.c b/drivers/md/md.c
index 261322722c19..97852099defd 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -3359,9 +3359,9 @@ static struct kobject *md_probe(dev_t dev, int *part, void *data)
3359 disk->queue = mddev->queue; 3359 disk->queue = mddev->queue;
3360 add_disk(disk); 3360 add_disk(disk);
3361 mddev->gendisk = disk; 3361 mddev->gendisk = disk;
3362 mutex_unlock(&disks_mutex);
3363 error = kobject_init_and_add(&mddev->kobj, &md_ktype, &disk->dev.kobj, 3362 error = kobject_init_and_add(&mddev->kobj, &md_ktype, &disk->dev.kobj,
3364 "%s", "md"); 3363 "%s", "md");
3364 mutex_unlock(&disks_mutex);
3365 if (error) 3365 if (error)
3366 printk(KERN_WARNING "md: cannot register %s/md - name in use\n", 3366 printk(KERN_WARNING "md: cannot register %s/md - name in use\n",
3367 disk->disk_name); 3367 disk->disk_name);