Skip to content

Commit

Permalink
[SCSI] raid class: handle component-add errors
Browse files Browse the repository at this point in the history
Signed-off-by: Jeff Garzik <jeff@garzik.org>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
  • Loading branch information
Jeff Garzik authored and James Bottomley committed Oct 4, 2006
1 parent 83aabc1 commit ed542be
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
20 changes: 16 additions & 4 deletions drivers/scsi/raid_class.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);

Expand Down
5 changes: 3 additions & 2 deletions include/linux/raid_class.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 *);

0 comments on commit ed542be

Please sign in to comment.