mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-06-07 15:18:15 +00:00
[SCSI] raid class: handle component-add errors
Signed-off-by: Jeff Garzik <jeff@garzik.org> Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
This commit is contained in:
parent
83aabc1be5
commit
ed542bed12
2 changed files with 19 additions and 6 deletions
|
@ -215,7 +215,7 @@ static void raid_component_release(struct class_device *cdev)
|
||||||
kfree(rc);
|
kfree(rc);
|
||||||
}
|
}
|
||||||
|
|
||||||
void raid_component_add(struct raid_template *r,struct device *raid_dev,
|
int raid_component_add(struct raid_template *r,struct device *raid_dev,
|
||||||
struct device *component_dev)
|
struct device *component_dev)
|
||||||
{
|
{
|
||||||
struct class_device *cdev =
|
struct class_device *cdev =
|
||||||
|
@ -223,10 +223,11 @@ void raid_component_add(struct raid_template *r,struct device *raid_dev,
|
||||||
raid_dev);
|
raid_dev);
|
||||||
struct raid_component *rc;
|
struct raid_component *rc;
|
||||||
struct raid_data *rd = class_get_devdata(cdev);
|
struct raid_data *rd = class_get_devdata(cdev);
|
||||||
|
int err;
|
||||||
|
|
||||||
rc = kzalloc(sizeof(*rc), GFP_KERNEL);
|
rc = kzalloc(sizeof(*rc), GFP_KERNEL);
|
||||||
if (!rc)
|
if (!rc)
|
||||||
return;
|
return -ENOMEM;
|
||||||
|
|
||||||
INIT_LIST_HEAD(&rc->node);
|
INIT_LIST_HEAD(&rc->node);
|
||||||
class_device_initialize(&rc->cdev);
|
class_device_initialize(&rc->cdev);
|
||||||
|
@ -239,7 +240,18 @@ void raid_component_add(struct raid_template *r,struct device *raid_dev,
|
||||||
list_add_tail(&rc->node, &rd->component_list);
|
list_add_tail(&rc->node, &rd->component_list);
|
||||||
rc->cdev.parent = cdev;
|
rc->cdev.parent = cdev;
|
||||||
rc->cdev.class = &raid_class.class;
|
rc->cdev.class = &raid_class.class;
|
||||||
class_device_add(&rc->cdev);
|
err = class_device_add(&rc->cdev);
|
||||||
|
if (err)
|
||||||
|
goto err_out;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
err_out:
|
||||||
|
list_del(&rc->node);
|
||||||
|
rd->component_count--;
|
||||||
|
put_device(component_dev);
|
||||||
|
kfree(rc);
|
||||||
|
return err;
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(raid_component_add);
|
EXPORT_SYMBOL(raid_component_add);
|
||||||
|
|
||||||
|
|
|
@ -77,5 +77,6 @@ DEFINE_RAID_ATTRIBUTE(enum raid_state, state)
|
||||||
struct raid_template *raid_class_attach(struct raid_function_template *);
|
struct raid_template *raid_class_attach(struct raid_function_template *);
|
||||||
void raid_class_release(struct raid_template *);
|
void raid_class_release(struct raid_template *);
|
||||||
|
|
||||||
void raid_component_add(struct raid_template *, struct device *,
|
int __must_check raid_component_add(struct raid_template *, struct device *,
|
||||||
struct device *);
|
struct device *);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue