[linux-cifs-client] Cannot allocate memory
diff mbox

Message ID 200903162136.31933.piastry@etersoft.ru
State New, archived
Headers show

Commit Message

Pavel Shilovsky March 16, 2009, 6:36 p.m. UTC
Signed-off-by: Pavel Shilovsky <piastryyy@gmail.com>
Acked-by: Jeff Layton <jlayton@redhat.com>

Patch
diff mbox

diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h
index 9fbf4df..a5989aa 100644
--- a/fs/cifs/cifsglob.h
+++ b/fs/cifs/cifsglob.h
@@ -182,6 +182,7 @@  struct TCP_Server_Info {
        struct mac_key mac_signing_key;
        char ntlmv2_hash[16];
        unsigned long lstrp; /* when we got last response from this server */
+       struct completion done;
 };

 /*
diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c
index cd4ccc8..480c48e 100644
--- a/fs/cifs/connect.c
+++ b/fs/cifs/connect.c
@@ -337,6 +337,7 @@  cifs_demultiplex_thread(struct TCP_Server_Info *server)
        bool isMultiRsp;
        int reconnect;

+       init_completion(&server->done);
        current->flags |= PF_MEMALLOC;
        cFYI(1, ("Demultiplex PID: %d", task_pid_nr(current)));

@@ -747,7 +748,6 @@  multi_t2_fnd:

        kfree(server->hostname);
        task_to_wake = xchg(&server->tsk, NULL);
-       kfree(server);

        length = atomic_dec_return(&tcpSesAllocCount);
        if (length  > 0)
@@ -764,6 +764,8 @@  multi_t2_fnd:
                set_current_state(TASK_RUNNING);
        }

+       complete_all(&server->done);
+
        module_put_and_exit(0);
 }

@@ -1418,6 +1420,10 @@  cifs_put_tcp_session(struct TCP_Server_Info *server)
        task = xchg(&server->tsk, NULL);
        if (task)
                force_sig(SIGKILL, task);
+
+       wait_for_completion_interruptible(&server->done);
+
+       kfree(server);
 }

 static struct TCP_Server_Info *