cifs: fix mid leak during reconnection after timeout threshold
authorShyam Prasad N <nspmangalore@gmail.com>
Fri, 14 Jul 2023 08:56:33 +0000 (08:56 +0000)
committerSteve French <stfrench@microsoft.com>
Fri, 14 Jul 2023 16:25:08 +0000 (11:25 -0500)
commit69cba9d3c1284e0838ae408830a02c4a063104bc
tree35d4e8047b55ccbbd49ee6bf35360aacd0a496e9
parentc071b34f62ddbf8435491ebb0e21eba9dc29f901
cifs: fix mid leak during reconnection after timeout threshold

When the number of responses with status of STATUS_IO_TIMEOUT
exceeds a specified threshold (NUM_STATUS_IO_TIMEOUT), we reconnect
the connection. But we do not return the mid, or the credits
returned for the mid, or reduce the number of in-flight requests.

This bug could result in the server->in_flight count to go bad,
and also cause a leak in the mids.

This change moves the check to a few lines below where the
response is decrypted, even of the response is read from the
transform header. This way, the code for returning the mids
can be reused.

Also, the cifs_reconnect was reconnecting just the transport
connection before. In case of multi-channel, this may not be
what we want to do after several timeouts. Changed that to
reconnect the session and the tree too.

Also renamed NUM_STATUS_IO_TIMEOUT to a more appropriate name
MAX_STATUS_IO_TIMEOUT.

Fixes: 8e670f77c4a5 ("Handle STATUS_IO_TIMEOUT gracefully")
Signed-off-by: Shyam Prasad N <sprasad@microsoft.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
fs/smb/client/connect.c