diff options
author | Al Viro <viro@ZenIV.linux.org.uk> | 2012-07-21 03:55:18 -0400 |
---|---|---|
committer | Nicholas Bellinger <nab@linux-iscsi.org> | 2012-07-21 05:44:13 -0400 |
commit | bf6932f44a7b3fa7e2246a8b18a44670e5eab6c2 (patch) | |
tree | d1a0ac63a2e2a04263b36ab6b4ff97bacbe88fa2 /drivers/target/iscsi/iscsi_target.c | |
parent | 2962846d14769e526b5d266f4af998b5a027b1d7 (diff) |
iscsi-target: Drop bogus struct file usage for iSCSI/SCTP
From Al Viro:
BTW, speaking of struct file treatment related to sockets -
there's this piece of code in iscsi:
/*
* The SCTP stack needs struct socket->file.
*/
if ((np->np_network_transport == ISCSI_SCTP_TCP) ||
(np->np_network_transport == ISCSI_SCTP_UDP)) {
if (!new_sock->file) {
new_sock->file = kzalloc(
sizeof(struct file), GFP_KERNEL);
For one thing, as far as I can see it'not true - sctp does *not* depend on
socket->file being non-NULL; it does, in one place, check socket->file->f_flags
for O_NONBLOCK, but there it treats NULL socket->file as "flag not set".
Which is the case here anyway - the fake struct file created in
__iscsi_target_login_thread() (and in iscsi_target_setup_login_socket(), with
the same excuse) do *not* get that flag set.
Moreover, it's a bloody serious violation of a bunch of asserts in VFS;
all struct file instances should come from filp_cachep, via get_empty_filp()
(or alloc_file(), which is a wrapper for it). FWIW, I'm very tempted to
do this and be done with the entire mess:
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Cc: Andy Grover <agrover@redhat.com>
Cc: Hannes Reinecke <hare@suse.de>
Cc: Christoph Hellwig <hch@lst.de>
Cc: stable@vger.kernel.org
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
Diffstat (limited to 'drivers/target/iscsi/iscsi_target.c')
-rw-r--r-- | drivers/target/iscsi/iscsi_target.c | 22 |
1 files changed, 3 insertions, 19 deletions
diff --git a/drivers/target/iscsi/iscsi_target.c b/drivers/target/iscsi/iscsi_target.c index 5d56ce44a6c5..97c0f78c3c9c 100644 --- a/drivers/target/iscsi/iscsi_target.c +++ b/drivers/target/iscsi/iscsi_target.c | |||
@@ -429,19 +429,8 @@ int iscsit_reset_np_thread( | |||
429 | 429 | ||
430 | int iscsit_del_np_comm(struct iscsi_np *np) | 430 | int iscsit_del_np_comm(struct iscsi_np *np) |
431 | { | 431 | { |
432 | if (!np->np_socket) | 432 | if (np->np_socket) |
433 | return 0; | 433 | sock_release(np->np_socket); |
434 | |||
435 | /* | ||
436 | * Some network transports allocate their own struct sock->file, | ||
437 | * see if we need to free any additional allocated resources. | ||
438 | */ | ||
439 | if (np->np_flags & NPF_SCTP_STRUCT_FILE) { | ||
440 | kfree(np->np_socket->file); | ||
441 | np->np_socket->file = NULL; | ||
442 | } | ||
443 | |||
444 | sock_release(np->np_socket); | ||
445 | return 0; | 434 | return 0; |
446 | } | 435 | } |
447 | 436 | ||
@@ -4079,13 +4068,8 @@ int iscsit_close_connection( | |||
4079 | kfree(conn->conn_ops); | 4068 | kfree(conn->conn_ops); |
4080 | conn->conn_ops = NULL; | 4069 | conn->conn_ops = NULL; |
4081 | 4070 | ||
4082 | if (conn->sock) { | 4071 | if (conn->sock) |
4083 | if (conn->conn_flags & CONNFLAG_SCTP_STRUCT_FILE) { | ||
4084 | kfree(conn->sock->file); | ||
4085 | conn->sock->file = NULL; | ||
4086 | } | ||
4087 | sock_release(conn->sock); | 4072 | sock_release(conn->sock); |
4088 | } | ||
4089 | conn->thread_set = NULL; | 4073 | conn->thread_set = NULL; |
4090 | 4074 | ||
4091 | pr_debug("Moving to TARG_CONN_STATE_FREE.\n"); | 4075 | pr_debug("Moving to TARG_CONN_STATE_FREE.\n"); |