]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
[SCSI] raid class: handle component-add errors
authorJeff Garzik <jeff@garzik.org>
Wed, 4 Oct 2006 11:05:11 +0000 (07:05 -0400)
committerJames Bottomley <jejb@mulgrave.il.steeleye.com>
Wed, 4 Oct 2006 18:27:26 +0000 (13:27 -0500)
Signed-off-by: Jeff Garzik <jeff@garzik.org>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
drivers/scsi/raid_class.c
include/linux/raid_class.h

index 327b33a57b0a1b865ce5c55e91f9c312f2e3d1ec..86e13183c9bab421418f3fb706662d0f24d6f666 100644 (file)
@@ -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);
 
index d0dd38b3a2fd8b0c14ea47d540eb4de9361080b5..d22ad392242ac811bf1c432c89b4c18592dbd987 100644 (file)
@@ -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 *);
+