diff mbox series

[v2,4/4] ksmbd: increment reference count of parent fp

Message ID 20220306011045.13014-4-linkinjeon@kernel.org
State New
Headers show
Series [1/4] ksmbd: remove internal.h include | expand

Commit Message

Namjae Jeon March 6, 2022, 1:10 a.m. UTC
Add missing increment reference count of parent fp in
ksmbd_lookup_fd_inode().

Cc: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
---
 v2:
   - switch the order of 3/4 and 4/4 patch.

 fs/ksmbd/vfs.c       | 2 ++
 fs/ksmbd/vfs_cache.c | 1 +
 2 files changed, 3 insertions(+)
diff mbox series

Patch

diff --git a/fs/ksmbd/vfs.c b/fs/ksmbd/vfs.c
index f703dbfe22c0..0b92092f3e8a 100644
--- a/fs/ksmbd/vfs.c
+++ b/fs/ksmbd/vfs.c
@@ -769,8 +769,10 @@  int ksmbd_vfs_rename(struct ksmbd_work *work, struct path *old_path,
 		if (parent_fp->daccess & FILE_DELETE_LE) {
 			pr_err("parent dir is opened with delete access\n");
 			err = -ESHARE;
+			ksmbd_fd_put(work, parent_fp);
 			goto out5;
 		}
+		ksmbd_fd_put(work, parent_fp);
 	}
 
 	rd.old_mnt_userns	= mnt_user_ns(old_path->mnt),
diff --git a/fs/ksmbd/vfs_cache.c b/fs/ksmbd/vfs_cache.c
index ffb534281836..df600eb04552 100644
--- a/fs/ksmbd/vfs_cache.c
+++ b/fs/ksmbd/vfs_cache.c
@@ -493,6 +493,7 @@  struct ksmbd_file *ksmbd_lookup_fd_inode(struct inode *inode)
 	list_for_each_entry(lfp, &ci->m_fp_list, node) {
 		if (inode == file_inode(lfp->filp)) {
 			atomic_dec(&ci->m_count);
+			lfp = ksmbd_fp_get(lfp);
 			read_unlock(&ci->m_lock);
 			return lfp;
 		}