diff options
author | Namjae Jeon <linkinjeon@kernel.org> | 2024-09-03 20:28:08 +0900 |
---|---|---|
committer | Steve French <stfrench@microsoft.com> | 2024-09-14 00:03:15 -0500 |
commit | ee426bfb9d09b29987369b897fe9b6485ac2be27 (patch) | |
tree | 46c5e8b0f908ca43083f27b0dadb8dbe5e60576d /fs/smb/server/vfs_cache.c | |
parent | 2fb9b5dc80cabcee636a6ccd020740dd925b4580 (diff) | |
download | linux-ee426bfb9d09b29987369b897fe9b6485ac2be27.tar.gz linux-ee426bfb9d09b29987369b897fe9b6485ac2be27.tar.bz2 linux-ee426bfb9d09b29987369b897fe9b6485ac2be27.zip |
ksmbd: add refcnt to ksmbd_conn struct
When sending an oplock break request, opinfo->conn is used,
But freed ->conn can be used on multichannel.
This patch add a reference count to the ksmbd_conn struct
so that it can be freed when it is no longer used.
Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
Signed-off-by: Steve French <stfrench@microsoft.com>
Diffstat (limited to 'fs/smb/server/vfs_cache.c')
-rw-r--r-- | fs/smb/server/vfs_cache.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/fs/smb/server/vfs_cache.c b/fs/smb/server/vfs_cache.c index 4d4ee696e37c..a19f4e563c7e 100644 --- a/fs/smb/server/vfs_cache.c +++ b/fs/smb/server/vfs_cache.c @@ -863,6 +863,8 @@ static bool session_fd_check(struct ksmbd_tree_connect *tcon, list_for_each_entry_rcu(op, &ci->m_op_list, op_entry) { if (op->conn != conn) continue; + if (op->conn && atomic_dec_and_test(&op->conn->refcnt)) + kfree(op->conn); op->conn = NULL; } up_write(&ci->m_lock); @@ -965,6 +967,7 @@ int ksmbd_reopen_durable_fd(struct ksmbd_work *work, struct ksmbd_file *fp) if (op->conn) continue; op->conn = fp->conn; + atomic_inc(&op->conn->refcnt); } up_write(&ci->m_lock); |