Commit a23a984f authored by Neil Brown's avatar Neil Brown Committed by Greg Kroah-Hartman

Close race in md_probe

[ Upstream commit f48ed538 ]

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: default avatarNeil Brown <neilb@suse.de>
CC: Oliver Pinter <oliver.pntr@gmail.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 97a9945a
...@@ -3326,9 +3326,9 @@ static struct kobject *md_probe(dev_t dev, int *part, void *data) ...@@ -3326,9 +3326,9 @@ static struct kobject *md_probe(dev_t dev, int *part, void *data)
disk->queue = mddev->queue; disk->queue = mddev->queue;
add_disk(disk); add_disk(disk);
mddev->gendisk = disk; mddev->gendisk = disk;
mutex_unlock(&disks_mutex);
error = kobject_init_and_add(&mddev->kobj, &md_ktype, &disk->dev.kobj, error = kobject_init_and_add(&mddev->kobj, &md_ktype, &disk->dev.kobj,
"%s", "md"); "%s", "md");
mutex_unlock(&disks_mutex);
if (error) if (error)
printk(KERN_WARNING "md: cannot register %s/md - name in use\n", printk(KERN_WARNING "md: cannot register %s/md - name in use\n",
disk->disk_name); disk->disk_name);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment