These changes are a raw update to a vanilla kernel 4.1.10, with the
[kvmfornfv.git] / kernel / drivers / infiniband / ulp / srp / ib_srp.c
index 75c01b2..025f931 100644 (file)
@@ -2761,6 +2761,13 @@ static int srp_sdev_count(struct Scsi_Host *host)
        return c;
 }
 
+/*
+ * Return values:
+ * < 0 upon failure. Caller is responsible for SRP target port cleanup.
+ * 0 and target->state == SRP_TARGET_REMOVED if asynchronous target port
+ *    removal has been scheduled.
+ * 0 and target->state != SRP_TARGET_REMOVED upon success.
+ */
 static int srp_add_target(struct srp_host *host, struct srp_target_port *target)
 {
        struct srp_rport_identifiers ids;
@@ -3266,7 +3273,7 @@ static ssize_t srp_create_target(struct device *dev,
                                        srp_free_ch_ib(target, ch);
                                        srp_free_req_data(target, ch);
                                        target->ch_count = ch - target->ch;
-                                       break;
+                                       goto connected;
                                }
                        }
 
@@ -3276,6 +3283,7 @@ static ssize_t srp_create_target(struct device *dev,
                node_idx++;
        }
 
+connected:
        target->scsi_host->nr_hw_queues = target->ch_count;
 
        ret = srp_add_target(host, target);
@@ -3298,6 +3306,8 @@ out:
        mutex_unlock(&host->add_target_mutex);
 
        scsi_host_put(target->scsi_host);
+       if (ret < 0)
+               scsi_host_put(target->scsi_host);
 
        return ret;