In preparation for running with added-but-disabled portals, the transport reference should be taken when the np is added. Signed-off-by: David Disseldorp <ddiss@xxxxxxx> --- drivers/target/iscsi/iscsi_target.c | 14 ++++++++++++++ drivers/target/iscsi/iscsi_target_login.c | 9 +-------- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/drivers/target/iscsi/iscsi_target.c b/drivers/target/iscsi/iscsi_target.c index 9dd5472..faaeef2 100644 --- a/drivers/target/iscsi/iscsi_target.c +++ b/drivers/target/iscsi/iscsi_target.c @@ -348,6 +348,7 @@ struct iscsi_np *iscsit_add_np( struct sockaddr_in6 *sock_in6; struct iscsi_np *np; int ret; + struct iscsit_transport *t; mutex_lock(&np_lock); @@ -384,13 +385,25 @@ struct iscsi_np *iscsit_add_np( */ memcpy(&np->np_sockaddr, sockaddr, sizeof(struct __kernel_sockaddr_storage)); + + t = iscsit_get_transport(network_transport); + if (!t) { + pr_err("unable to get network transport %d\n", + network_transport); + kfree(np); + mutex_unlock(&np_lock); + return ERR_PTR(-EINVAL); + } + np->np_transport = t; np->np_network_transport = network_transport; + spin_lock_init(&np->np_thread_lock); init_completion(&np->np_restart_comp); INIT_LIST_HEAD(&np->np_list); ret = iscsi_target_setup_login_socket(np, sockaddr); if (ret != 0) { + iscsit_put_transport(np->np_transport); kfree(np); mutex_unlock(&np_lock); return ERR_PTR(ret); @@ -400,6 +413,7 @@ struct iscsi_np *iscsit_add_np( if (IS_ERR(np->np_thread)) { pr_err("Unable to create kthread: iscsi_np\n"); ret = PTR_ERR(np->np_thread); + iscsit_put_transport(np->np_transport); kfree(np); mutex_unlock(&np_lock); return ERR_PTR(ret); diff --git a/drivers/target/iscsi/iscsi_target_login.c b/drivers/target/iscsi/iscsi_target_login.c index fac45fb..6c1cd2e 100644 --- a/drivers/target/iscsi/iscsi_target_login.c +++ b/drivers/target/iscsi/iscsi_target_login.c @@ -972,20 +972,13 @@ int iscsi_target_setup_login_socket( struct iscsi_np *np, struct __kernel_sockaddr_storage *sockaddr) { - struct iscsit_transport *t; int rc; - t = iscsit_get_transport(np->np_network_transport); - if (!t) - return -EINVAL; - - rc = t->iscsit_setup_np(np, sockaddr); + rc = np->np_transport->iscsit_setup_np(np, &np->np_sockaddr); if (rc < 0) { - iscsit_put_transport(t); return rc; } - np->np_transport = t; np->enabled = true; return 0; } -- 2.1.4 -- To unsubscribe from this list: send the line "unsubscribe target-devel" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html