diff options
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/scsi/raid_class.c | 20 |
1 files changed, 16 insertions, 4 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) | |||
215 | kfree(rc); | 215 | kfree(rc); |
216 | } | 216 | } |
217 | 217 | ||
218 | void raid_component_add(struct raid_template *r,struct device *raid_dev, | 218 | int raid_component_add(struct raid_template *r,struct device *raid_dev, |
219 | struct device *component_dev) | 219 | struct device *component_dev) |
220 | { | 220 | { |
221 | struct class_device *cdev = | 221 | struct class_device *cdev = |
222 | attribute_container_find_class_device(&r->raid_attrs.ac, | 222 | attribute_container_find_class_device(&r->raid_attrs.ac, |
223 | raid_dev); | 223 | raid_dev); |
224 | struct raid_component *rc; | 224 | struct raid_component *rc; |
225 | struct raid_data *rd = class_get_devdata(cdev); | 225 | struct raid_data *rd = class_get_devdata(cdev); |
226 | int err; | ||
226 | 227 | ||
227 | rc = kzalloc(sizeof(*rc), GFP_KERNEL); | 228 | rc = kzalloc(sizeof(*rc), GFP_KERNEL); |
228 | if (!rc) | 229 | if (!rc) |
229 | return; | 230 | return -ENOMEM; |
230 | 231 | ||
231 | INIT_LIST_HEAD(&rc->node); | 232 | INIT_LIST_HEAD(&rc->node); |
232 | class_device_initialize(&rc->cdev); | 233 | class_device_initialize(&rc->cdev); |
@@ -239,7 +240,18 @@ void raid_component_add(struct raid_template *r,struct device *raid_dev, | |||
239 | list_add_tail(&rc->node, &rd->component_list); | 240 | list_add_tail(&rc->node, &rd->component_list); |
240 | rc->cdev.parent = cdev; | 241 | rc->cdev.parent = cdev; |
241 | rc->cdev.class = &raid_class.class; | 242 | rc->cdev.class = &raid_class.class; |
242 | class_device_add(&rc->cdev); | 243 | err = class_device_add(&rc->cdev); |
244 | if (err) | ||
245 | goto err_out; | ||
246 | |||
247 | return 0; | ||
248 | |||
249 | err_out: | ||
250 | list_del(&rc->node); | ||
251 | rd->component_count--; | ||
252 | put_device(component_dev); | ||
253 | kfree(rc); | ||
254 | return err; | ||
243 | } | 255 | } |
244 | EXPORT_SYMBOL(raid_component_add); | 256 | EXPORT_SYMBOL(raid_component_add); |
245 | 257 | ||