diff mbox

[resend] cifs: Do not modify mid entry after submitting I/O in cifs_call_async

Message ID 1498673154-30879-1-git-send-email-longli@exchange.microsoft.com (mailing list archive)
State New, archived
Headers show

Commit Message

Long Li June 28, 2017, 6:05 p.m. UTC
From: Long Li <longli@microsoft.com>

In cifs_call_async, server response may return as soon as I/O is submitted.
Because mid entry is freed on the return path, do not modify it after I/O is
submitted.

Signed-off-by: Long Li <longli@microsoft.com>
---
 fs/cifs/transport.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Pavel Shilovsky June 28, 2017, 6:23 p.m. UTC | #1
2017-06-28 11:05 GMT-07:00 Long Li <longli@exchange.microsoft.com>:
> From: Long Li <longli@microsoft.com>
>
> In cifs_call_async, server response may return as soon as I/O is submitted.
> Because mid entry is freed on the return path, do not modify it after I/O is
> submitted.
>
> Signed-off-by: Long Li <longli@microsoft.com>
> ---
>  fs/cifs/transport.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fs/cifs/transport.c b/fs/cifs/transport.c
> index 47a125e..ba62aaf 100644
> --- a/fs/cifs/transport.c
> +++ b/fs/cifs/transport.c
> @@ -537,10 +537,10 @@ cifs_call_async(struct TCP_Server_Info *server, struct smb_rqst *rqst,
>         spin_unlock(&GlobalMid_Lock);
>
>
> +       cifs_save_when_sent(mid);
>         cifs_in_send_inc(server);
>         rc = smb_send_rqst(server, rqst, flags);
>         cifs_in_send_dec(server);
> -       cifs_save_when_sent(mid);
>
>         if (rc < 0) {
>                 server->sequence_number -= 2;
> --
> 2.7.4
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-cifs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

Looks good. Could you please add an additional comment describing the
behavior in the code?

--
Best regards,
Pavel Shilovsky
--
To unsubscribe from this list: send the line "unsubscribe linux-cifs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Long Li June 28,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majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/fs/cifs/transport.c b/fs/cifs/transport.c
index 47a125e..ba62aaf 100644
--- a/fs/cifs/transport.c
+++ b/fs/cifs/transport.c
@@ -537,10 +537,10 @@  cifs_call_async(struct TCP_Server_Info *server, struct smb_rqst *rqst,
 	spin_unlock(&GlobalMid_Lock);
 
 
+	cifs_save_when_sent(mid);
 	cifs_in_send_inc(server);
 	rc = smb_send_rqst(server, rqst, flags);
 	cifs_in_send_dec(server);
-	cifs_save_when_sent(mid);
 
 	if (rc < 0) {
 		server->sequence_number -= 2;