diff options
Diffstat (limited to 'fs')
-rw-r--r-- | fs/partitions/check.c | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/fs/partitions/check.c b/fs/partitions/check.c index efef715135d3..2e6413fbd2d8 100644 --- a/fs/partitions/check.c +++ b/fs/partitions/check.c | |||
@@ -344,18 +344,18 @@ static ssize_t whole_disk_show(struct device *dev, | |||
344 | static DEVICE_ATTR(whole_disk, S_IRUSR | S_IRGRP | S_IROTH, | 344 | static DEVICE_ATTR(whole_disk, S_IRUSR | S_IRGRP | S_IROTH, |
345 | whole_disk_show, NULL); | 345 | whole_disk_show, NULL); |
346 | 346 | ||
347 | void add_partition(struct gendisk *disk, int part, sector_t start, sector_t len, int flags) | 347 | int add_partition(struct gendisk *disk, int part, sector_t start, sector_t len, int flags) |
348 | { | 348 | { |
349 | struct hd_struct *p; | 349 | struct hd_struct *p; |
350 | int err; | 350 | int err; |
351 | 351 | ||
352 | p = kzalloc(sizeof(*p), GFP_KERNEL); | 352 | p = kzalloc(sizeof(*p), GFP_KERNEL); |
353 | if (!p) | 353 | if (!p) |
354 | return; | 354 | return -ENOMEM; |
355 | 355 | ||
356 | if (!init_part_stats(p)) { | 356 | if (!init_part_stats(p)) { |
357 | kfree(p); | 357 | err = -ENOMEM; |
358 | return; | 358 | goto out0; |
359 | } | 359 | } |
360 | p->start_sect = start; | 360 | p->start_sect = start; |
361 | p->nr_sects = len; | 361 | p->nr_sects = len; |
@@ -378,15 +378,31 @@ void add_partition(struct gendisk *disk, int part, sector_t start, sector_t len, | |||
378 | 378 | ||
379 | /* delay uevent until 'holders' subdir is created */ | 379 | /* delay uevent until 'holders' subdir is created */ |
380 | p->dev.uevent_suppress = 1; | 380 | p->dev.uevent_suppress = 1; |
381 | device_add(&p->dev); | 381 | err = device_add(&p->dev); |
382 | if (err) | ||
383 | goto out1; | ||
382 | partition_sysfs_add_subdir(p); | 384 | partition_sysfs_add_subdir(p); |
383 | p->dev.uevent_suppress = 0; | 385 | p->dev.uevent_suppress = 0; |
384 | if (flags & ADDPART_FLAG_WHOLEDISK) | 386 | if (flags & ADDPART_FLAG_WHOLEDISK) { |
385 | err = device_create_file(&p->dev, &dev_attr_whole_disk); | 387 | err = device_create_file(&p->dev, &dev_attr_whole_disk); |
388 | if (err) | ||
389 | goto out2; | ||
390 | } | ||
386 | 391 | ||
387 | /* suppress uevent if the disk supresses it */ | 392 | /* suppress uevent if the disk supresses it */ |
388 | if (!disk->dev.uevent_suppress) | 393 | if (!disk->dev.uevent_suppress) |
389 | kobject_uevent(&p->dev.kobj, KOBJ_ADD); | 394 | kobject_uevent(&p->dev.kobj, KOBJ_ADD); |
395 | |||
396 | return 0; | ||
397 | |||
398 | out2: | ||
399 | device_del(&p->dev); | ||
400 | out1: | ||
401 | put_device(&p->dev); | ||
402 | free_part_stats(p); | ||
403 | out0: | ||
404 | kfree(p); | ||
405 | return err; | ||
390 | } | 406 | } |
391 | 407 | ||
392 | /* Not exported, helper to add_disk(). */ | 408 | /* Not exported, helper to add_disk(). */ |