]> err.no Git - linux-2.6/blobdiff - drivers/scsi/scsi_scan.c
fix mismerge in ll_rw_blk.c
[linux-2.6] / drivers / scsi / scsi_scan.c
index ad3a5b1424686cd4c3c192d07c0377c548ded325..48edd67982a5f85e8b6f5f2b842240fb5fbfc0d2 100644 (file)
@@ -336,9 +336,23 @@ static struct scsi_target *scsi_alloc_target(struct device *parent,
        unsigned long flags;
        const int size = sizeof(struct scsi_target)
                + shost->transportt->target_size;
-       struct scsi_target *starget = kmalloc(size, GFP_ATOMIC);
+       struct scsi_target *starget;
        struct scsi_target *found_target;
 
+       /*
+        * Obtain the real parent from the transport. The transport
+        * is allowed to fail (no error) if there is nothing at that
+        * target id.
+        */
+       if (shost->transportt->target_parent) {
+               spin_lock_irqsave(shost->host_lock, flags);
+               parent = shost->transportt->target_parent(shost, channel, id);
+               spin_unlock_irqrestore(shost->host_lock, flags);
+               if (!parent)
+                       return NULL;
+       }
+
+       starget = kmalloc(size, GFP_KERNEL);
        if (!starget) {
                printk(KERN_ERR "%s: allocation failure\n", __FUNCTION__);
                return NULL;
@@ -756,7 +770,8 @@ static int scsi_add_lun(struct scsi_device *sdev, char *inq_result, int *bflags)
         * register it and tell the rest of the kernel
         * about it.
         */
-       scsi_sysfs_add_sdev(sdev);
+       if (scsi_sysfs_add_sdev(sdev) != 0)
+               return SCSI_SCAN_NO_RESPONSE;
 
        return SCSI_SCAN_LUN_PRESENT;
 }