|
@@ -344,18 +344,18 @@ static ssize_t whole_disk_show(struct device *dev,
|
|
static DEVICE_ATTR(whole_disk, S_IRUSR | S_IRGRP | S_IROTH,
|
|
static DEVICE_ATTR(whole_disk, S_IRUSR | S_IRGRP | S_IROTH,
|
|
whole_disk_show, NULL);
|
|
whole_disk_show, NULL);
|
|
|
|
|
|
-void add_partition(struct gendisk *disk, int part, sector_t start, sector_t len, int flags)
|
|
|
|
|
|
+int add_partition(struct gendisk *disk, int part, sector_t start, sector_t len, int flags)
|
|
{
|
|
{
|
|
struct hd_struct *p;
|
|
struct hd_struct *p;
|
|
int err;
|
|
int err;
|
|
|
|
|
|
p = kzalloc(sizeof(*p), GFP_KERNEL);
|
|
p = kzalloc(sizeof(*p), GFP_KERNEL);
|
|
if (!p)
|
|
if (!p)
|
|
- return;
|
|
|
|
|
|
+ return -ENOMEM;
|
|
|
|
|
|
if (!init_part_stats(p)) {
|
|
if (!init_part_stats(p)) {
|
|
- kfree(p);
|
|
|
|
- return;
|
|
|
|
|
|
+ err = -ENOMEM;
|
|
|
|
+ goto out0;
|
|
}
|
|
}
|
|
p->start_sect = start;
|
|
p->start_sect = start;
|
|
p->nr_sects = len;
|
|
p->nr_sects = len;
|
|
@@ -378,15 +378,31 @@ void add_partition(struct gendisk *disk, int part, sector_t start, sector_t len,
|
|
|
|
|
|
/* delay uevent until 'holders' subdir is created */
|
|
/* delay uevent until 'holders' subdir is created */
|
|
p->dev.uevent_suppress = 1;
|
|
p->dev.uevent_suppress = 1;
|
|
- device_add(&p->dev);
|
|
|
|
|
|
+ err = device_add(&p->dev);
|
|
|
|
+ if (err)
|
|
|
|
+ goto out1;
|
|
partition_sysfs_add_subdir(p);
|
|
partition_sysfs_add_subdir(p);
|
|
p->dev.uevent_suppress = 0;
|
|
p->dev.uevent_suppress = 0;
|
|
- if (flags & ADDPART_FLAG_WHOLEDISK)
|
|
|
|
|
|
+ if (flags & ADDPART_FLAG_WHOLEDISK) {
|
|
err = device_create_file(&p->dev, &dev_attr_whole_disk);
|
|
err = device_create_file(&p->dev, &dev_attr_whole_disk);
|
|
|
|
+ if (err)
|
|
|
|
+ goto out2;
|
|
|
|
+ }
|
|
|
|
|
|
/* suppress uevent if the disk supresses it */
|
|
/* suppress uevent if the disk supresses it */
|
|
if (!disk->dev.uevent_suppress)
|
|
if (!disk->dev.uevent_suppress)
|
|
kobject_uevent(&p->dev.kobj, KOBJ_ADD);
|
|
kobject_uevent(&p->dev.kobj, KOBJ_ADD);
|
|
|
|
+
|
|
|
|
+ return 0;
|
|
|
|
+
|
|
|
|
+out2:
|
|
|
|
+ device_del(&p->dev);
|
|
|
|
+out1:
|
|
|
|
+ put_device(&p->dev);
|
|
|
|
+ free_part_stats(p);
|
|
|
|
+out0:
|
|
|
|
+ kfree(p);
|
|
|
|
+ return err;
|
|
}
|
|
}
|
|
|
|
|
|
/* Not exported, helper to add_disk(). */
|
|
/* Not exported, helper to add_disk(). */
|