]> Pileus Git - ~andy/linux/commitdiff
iscsi-target: Fix iscsit_transport reference leak during NP thread reset
authorNicholas Bellinger <nab@linux-iscsi.org>
Sun, 18 Aug 2013 22:07:44 +0000 (15:07 -0700)
committerNicholas Bellinger <nab@linux-iscsi.org>
Sat, 24 Aug 2013 03:30:46 +0000 (20:30 -0700)
This patch fixes a bug in __iscsi_target_login_thread() where an explicit
network portal thread reset ends up leaking the iscsit_transport module
reference, along with the associated iscsi_conn allocation.

This manifests itself with iser-target where a NP reset causes the extra
iscsit_transport reference to be taken in iscsit_conn_set_transport()
during the reset, which prevents the ib_isert module from being unloaded
after the NP thread shutdown has finished.

Cc: stable@vger.kernel.org # v3.10+
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
drivers/target/iscsi/iscsi_target_login.c

index 3402241be87cd401b500da10a398cb734e62bf8b..bc788c52b6cc861d9c2dfd3753b723c70f09b7b0 100644 (file)
@@ -1163,12 +1163,11 @@ static int __iscsi_target_login_thread(struct iscsi_np *np)
                if (np->np_thread_state == ISCSI_NP_THREAD_RESET) {
                        spin_unlock_bh(&np->np_thread_lock);
                        complete(&np->np_restart_comp);
-                       if (ret == -ENODEV) {
-                               iscsit_put_transport(conn->conn_transport);
-                               kfree(conn);
-                               conn = NULL;
+                       iscsit_put_transport(conn->conn_transport);
+                       kfree(conn);
+                       conn = NULL;
+                       if (ret == -ENODEV)
                                goto out;
-                       }
                        /* Get another socket */
                        return 1;
                }