aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/scsi_scan.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/scsi/scsi_scan.c')
-rw-r--r--drivers/scsi/scsi_scan.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c
index 84f01fd0c8fd..be14f9d82fde 100644
--- a/drivers/scsi/scsi_scan.c
+++ b/drivers/scsi/scsi_scan.c
@@ -332,6 +332,7 @@ static struct scsi_target *scsi_alloc_target(struct device *parent,
332 + shost->transportt->target_size; 332 + shost->transportt->target_size;
333 struct scsi_target *starget; 333 struct scsi_target *starget;
334 struct scsi_target *found_target; 334 struct scsi_target *found_target;
335 int error;
335 336
336 starget = kzalloc(size, GFP_KERNEL); 337 starget = kzalloc(size, GFP_KERNEL);
337 if (!starget) { 338 if (!starget) {
@@ -361,10 +362,20 @@ static struct scsi_target *scsi_alloc_target(struct device *parent,
361 spin_unlock_irqrestore(shost->host_lock, flags); 362 spin_unlock_irqrestore(shost->host_lock, flags);
362 /* allocate and add */ 363 /* allocate and add */
363 transport_setup_device(dev); 364 transport_setup_device(dev);
364 device_add(dev); 365 error = device_add(dev);
366 if (error) {
367 dev_err(dev, "target device_add failed, error %d\n", error);
368 spin_lock_irqsave(shost->host_lock, flags);
369 list_del_init(&starget->siblings);
370 spin_unlock_irqrestore(shost->host_lock, flags);
371 transport_destroy_device(dev);
372 put_device(parent);
373 kfree(starget);
374 return NULL;
375 }
365 transport_add_device(dev); 376 transport_add_device(dev);
366 if (shost->hostt->target_alloc) { 377 if (shost->hostt->target_alloc) {
367 int error = shost->hostt->target_alloc(starget); 378 error = shost->hostt->target_alloc(starget);
368 379
369 if(error) { 380 if(error) {
370 dev_printk(KERN_ERR, dev, "target allocation failed, error %d\n", error); 381 dev_printk(KERN_ERR, dev, "target allocation failed, error %d\n", error);