diff options
author | Jeff Garzik <jeff@garzik.org> | 2006-10-04 13:05:11 +0200 |
---|---|---|
committer | James Bottomley <jejb@mulgrave.il.steeleye.com> | 2006-10-04 20:27:26 +0200 |
commit | ed542bed126caeefc6546b276e4af852d4d34f33 (patch) | |
tree | f81d7a0c6b997dc32b933fe39ed3a1d891d4d3c8 | |
parent | [SCSI] SCSI megaraid_sas: handle thrown errors (diff) | |
download | linux-ed542bed126caeefc6546b276e4af852d4d34f33.tar.xz linux-ed542bed126caeefc6546b276e4af852d4d34f33.zip |
[SCSI] raid class: handle component-add errors
Signed-off-by: Jeff Garzik <jeff@garzik.org>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
-rw-r--r-- | drivers/scsi/raid_class.c | 20 | ||||
-rw-r--r-- | include/linux/raid_class.h | 5 |
2 files changed, 19 insertions, 6 deletions
diff --git a/drivers/scsi/raid_class.c b/drivers/scsi/raid_class.c index 327b33a57b0a..86e13183c9ba 100644 --- a/drivers/scsi/raid_class.c +++ b/drivers/scsi/raid_class.c @@ -215,18 +215,19 @@ static void raid_component_release(struct class_device *cdev) kfree(rc); } -void raid_component_add(struct raid_template *r,struct device *raid_dev, - struct device *component_dev) +int raid_component_add(struct raid_template *r,struct device *raid_dev, + struct device *component_dev) { struct class_device *cdev = attribute_container_find_class_device(&r->raid_attrs.ac, raid_dev); struct raid_component *rc; struct raid_data *rd = class_get_devdata(cdev); + int err; rc = kzalloc(sizeof(*rc), GFP_KERNEL); if (!rc) - return; + return -ENOMEM; INIT_LIST_HEAD(&rc->node); 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); rc->cdev.parent = cdev; 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); diff --git a/include/linux/raid_class.h b/include/linux/raid_class.h index d0dd38b3a2fd..d22ad392242a 100644 --- a/include/linux/raid_class.h +++ b/include/linux/raid_class.h @@ -77,5 +77,6 @@ DEFINE_RAID_ATTRIBUTE(enum raid_state, state) struct raid_template *raid_class_attach(struct raid_function_template *); void raid_class_release(struct raid_template *); -void raid_component_add(struct raid_template *, struct device *, - struct device *); +int __must_check raid_component_add(struct raid_template *, struct device *, + struct device *); + |