]> git.hungrycats.org Git - linux/commitdiff
IB/srp: Stop the scsi_eh_<n> and scsi_tmf_<n> threads if login fails
authorBart Van Assche <bart.vanassche@sandisk.com>
Fri, 14 Aug 2015 18:01:09 +0000 (11:01 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 29 Sep 2015 17:33:34 +0000 (19:33 +0200)
commit bc44bd1d864664f3658352c6aaaa02557d49165d upstream.

scsi_host_alloc() not only allocates memory for a SCSI host but also
creates the scsi_eh_<n> kernel thread and the scsi_tmf_<n> workqueue.
Stop these threads if login fails by calling scsi_host_put().

Reported-by: Konstantin Krotov <kkv@clodo.ru>
Fixes: fb49c8bbaae7 ("Remove an extraneous scsi_host_put() from an error path")
Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
Cc: Sagi Grimberg <sagig@mellanox.com>
Cc: Sebastian Parschauer <sebastian.riemer@profitbricks.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/infiniband/ulp/srp/ib_srp.c

index 2875d0bc1a3218f5d09d7bb872ad4a80b0837fd4..ffda44ff9375b98a9c4195a8c9eaeed6aebba2c7 100644 (file)
@@ -2757,6 +2757,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;
@@ -3295,6 +3302,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;