summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNeilBrown <neilb@suse.de>2005-11-08 21:39:28 -0800
committerLinus Torvalds <torvalds@g5.osdl.org>2005-11-09 07:56:37 -0800
commit9c79197761b4c181a143dc6a6044f4e47d44bdcc (patch)
tree2b0f75aac9cab625f5e5b27ae5e4f30d2838c486
parentd6065f7bf8bec170c9c56524a250093ce73ca5d9 (diff)
downloadlinux-3.10-9c79197761b4c181a143dc6a6044f4e47d44bdcc.tar.gz
linux-3.10-9c79197761b4c181a143dc6a6044f4e47d44bdcc.tar.bz2
linux-3.10-9c79197761b4c181a143dc6a6044f4e47d44bdcc.zip
[PATCH] md: fix ref-counting problems with kobjects in md
Thanks Greg. Cc: Greg KH <greg@kroah.com> Signed-off-by: Neil Brown <neilb@suse.de> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
-rw-r--r--drivers/md/md.c8
-rw-r--r--drivers/md/raid5.c2
2 files changed, 7 insertions, 3 deletions
diff --git a/drivers/md/md.c b/drivers/md/md.c
index e58d61d9f31..fe0137a5b00 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -805,7 +805,11 @@ static void super_90_sync(mddev_t *mddev, mdk_rdev_t *rdev)
if (fixdesc & (1<<rdev2->desc_nr)) {
snprintf(rdev2->kobj.name, KOBJ_NAME_LEN, "dev%d",
rdev2->desc_nr);
+ /* kobject_add gets a ref on the parent, so
+ * we have to drop the one we already have
+ */
kobject_add(&rdev2->kobj);
+ kobject_put(rdev->kobj.parent);
sysfs_create_link(&rdev2->kobj,
&rdev2->bdev->bd_disk->kobj,
"block");
@@ -1178,7 +1182,7 @@ static int bind_rdev_to_array(mdk_rdev_t * rdev, mddev_t * mddev)
rdev->kobj.k_name = NULL;
snprintf(rdev->kobj.name, KOBJ_NAME_LEN, "dev%d", rdev->desc_nr);
- rdev->kobj.parent = kobject_get(&mddev->kobj);
+ rdev->kobj.parent = &mddev->kobj;
kobject_add(&rdev->kobj);
sysfs_create_link(&rdev->kobj, &rdev->bdev->bd_disk->kobj, "block");
@@ -1864,7 +1868,7 @@ static struct kobject *md_probe(dev_t dev, int *part, void *data)
add_disk(disk);
mddev->gendisk = disk;
up(&disks_sem);
- mddev->kobj.parent = kobject_get(&disk->kobj);
+ mddev->kobj.parent = &disk->kobj;
mddev->kobj.k_name = NULL;
snprintf(mddev->kobj.name, KOBJ_NAME_LEN, "%s", "md");
mddev->kobj.ktype = &md_ktype;
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index 061d265ed94..246c9b1cc4a 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -1975,7 +1975,7 @@ memory = conf->max_nr_stripes * (sizeof(struct stripe_head) +
}
/* Ok, everything is just fine now */
- conf->kobj.parent = kobject_get(&mddev->kobj);
+ conf->kobj.parent = &mddev->kobj;
strcpy(conf->kobj.name, "raid5");
conf->kobj.ktype = &raid5_ktype;
kobject_register(&conf->kobj);