aboutsummaryrefslogtreecommitdiffstats
path: root/fs/partitions/check.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/partitions/check.c')
-rw-r--r--fs/partitions/check.c50
1 files changed, 42 insertions, 8 deletions
diff --git a/fs/partitions/check.c b/fs/partitions/check.c
index 51c6a748df49..6fb4b6150d77 100644
--- a/fs/partitions/check.c
+++ b/fs/partitions/check.c
@@ -376,18 +376,48 @@ static char *make_block_name(struct gendisk *disk)
376 return name; 376 return name;
377} 377}
378 378
379static void disk_sysfs_symlinks(struct gendisk *disk) 379static int disk_sysfs_symlinks(struct gendisk *disk)
380{ 380{
381 struct device *target = get_device(disk->driverfs_dev); 381 struct device *target = get_device(disk->driverfs_dev);
382 int err;
383 char *disk_name = NULL;
384
382 if (target) { 385 if (target) {
383 char *disk_name = make_block_name(disk); 386 disk_name = make_block_name(disk);
384 sysfs_create_link(&disk->kobj,&target->kobj,"device"); 387 if (!disk_name) {
385 if (disk_name) { 388 err = -ENOMEM;
386 sysfs_create_link(&target->kobj,&disk->kobj,disk_name); 389 goto err_out;
387 kfree(disk_name);
388 } 390 }
391
392 err = sysfs_create_link(&disk->kobj, &target->kobj, "device");
393 if (err)
394 goto err_out_disk_name;
395
396 err = sysfs_create_link(&target->kobj, &disk->kobj, disk_name);
397 if (err)
398 goto err_out_dev_link;
389 } 399 }
390 sysfs_create_link(&disk->kobj, &block_subsys.kset.kobj, "subsystem"); 400
401 err = sysfs_create_link(&disk->kobj, &block_subsys.kset.kobj,
402 "subsystem");
403 if (err)
404 goto err_out_disk_name_lnk;
405
406 kfree(disk_name);
407
408 return 0;
409
410err_out_disk_name_lnk:
411 if (target) {
412 sysfs_remove_link(&target->kobj, disk_name);
413err_out_dev_link:
414 sysfs_remove_link(&disk->kobj, "device");
415err_out_disk_name:
416 kfree(disk_name);
417err_out:
418 put_device(target);
419 }
420 return err;
391} 421}
392 422
393/* Not exported, helper to add_disk(). */ 423/* Not exported, helper to add_disk(). */
@@ -406,7 +436,11 @@ void register_disk(struct gendisk *disk)
406 *s = '!'; 436 *s = '!';
407 if ((err = kobject_add(&disk->kobj))) 437 if ((err = kobject_add(&disk->kobj)))
408 return; 438 return;
409 disk_sysfs_symlinks(disk); 439 err = disk_sysfs_symlinks(disk);
440 if (err) {
441 kobject_del(&disk->kobj);
442 return;
443 }
410 disk_sysfs_add_subdirs(disk); 444 disk_sysfs_add_subdirs(disk);
411 445
412 /* No minors to use for partitions */ 446 /* No minors to use for partitions */