summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeil Brown <neilb@suse.de>2008-07-31 20:46:13 +0200
committerGreg Kroah-Hartman <gregkh@suse.de>2008-08-06 09:03:13 -0700
commita23a984f8413296fc7656c0593717d9618e6548e (patch)
tree71b48c85e5df654736dad9831032d0f73e432fd2
parent97a9945a6459ff63dc904d412e6c137b68d0d7d0 (diff)
downloadlinux-stable-a23a984f8413296fc7656c0593717d9618e6548e.tar.gz
linux-stable-a23a984f8413296fc7656c0593717d9618e6548e.tar.bz2
linux-stable-a23a984f8413296fc7656c0593717d9618e6548e.zip
Close race in md_probe
[ Upstream commit f48ed538386cb41559282d989354e8f5d442d71c ] 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> CC: Oliver Pinter <oliver.pntr@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
-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 2580ac1b9b0f..96645111166c 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -3326,9 +3326,9 @@ static struct kobject *md_probe(dev_t dev, int *part, void *data)
disk->queue = mddev->queue;
add_disk(disk);
mddev->gendisk = disk;
- mutex_unlock(&disks_mutex);
error = kobject_init_and_add(&mddev->kobj, &md_ktype, &disk->dev.kobj,
"%s", "md");
+ mutex_unlock(&disks_mutex);
if (error)
printk(KERN_WARNING "md: cannot register %s/md - name in use\n",
disk->disk_name);