Skip to content

Commit

Permalink
cifs: unlock chan_lock before calling cifs_put_tcp_session
Browse files Browse the repository at this point in the history
While removing an smb session, we need to free up the
tcp session for each channel for that session. We were
doing this with chan_lock held. This results in a
cyclic dependency with cifs_tcp_ses_lock.

For now, unlock the chan_lock temporarily before calling
cifs_put_tcp_session. This should not cause any problem
for now, since we do not remove channels anywhere else.
And this code segment will not be called by two threads.

When we do implement the code for removing channels, we
will need to execute proper ref counting here.

Signed-off-by: Shyam Prasad N <sprasad@microsoft.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
  • Loading branch information
sprasad-microsoft authored and Steve French committed Jan 29, 2022
1 parent 483529f commit 489f710
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions fs/cifs/connect.c
Original file line number Diff line number Diff line change
Expand Up @@ -1831,13 +1831,9 @@ void cifs_put_smb_ses(struct cifs_ses *ses)
int i;

for (i = 1; i < chan_count; i++) {
/*
* note: for now, we're okay accessing ses->chans
* without chan_lock. But when chans can go away, we'll
* need to introduce ref counting to make sure that chan
* is not freed from under us.
*/
spin_unlock(&ses->chan_lock);
cifs_put_tcp_session(ses->chans[i].server, 0);
spin_lock(&ses->chan_lock);
ses->chans[i].server = NULL;
}
}
Expand Down

0 comments on commit 489f710

Please sign in to comment.