diff mbox series

[3/4] smb: client: Protect tcon->status with tc_lock spin lock

Message ID 8ba54b531064f48c90bdac82dfc43efedaaaed71.1701060106.git.pierre.mariani@gmail.com (mailing list archive)
State New, archived
Headers show
Series [1/4] smb: client: Delete unused value | expand

Commit Message

Pierre Mariani Nov. 27, 2023, 4:52 a.m. UTC
Protect the update of tcon->status with tc_lock spin lock as per documentation
from cifsglob.h.
Fixes Coverity 1560722 Data race condition.

Signed-off-by: Pierre Mariani <pierre.mariani@gmail.com>
---
 fs/smb/client/connect.c | 2 ++
 1 file changed, 2 insertions(+)
diff mbox series

Patch

diff --git a/fs/smb/client/connect.c b/fs/smb/client/connect.c
index 0512835f399c..a381c4cdb8c4 100644
--- a/fs/smb/client/connect.c
+++ b/fs/smb/client/connect.c
@@ -2710,7 +2710,9 @@  cifs_get_tcon(struct cifs_ses *ses, struct smb3_fs_context *ctx)
 	tcon->nodelete = ctx->nodelete;
 	tcon->local_lease = ctx->local_lease;
 	INIT_LIST_HEAD(&tcon->pending_opens);
+	spin_lock(&tcon->tc_lock);
 	tcon->status = TID_GOOD;
+	spin_unlock(&tcon->tc_lock);
 
 	INIT_DELAYED_WORK(&tcon->query_interfaces,
 			  smb2_query_server_interfaces);