Closed mmakassikis closed 1 year ago
@mmakassikis Okay, old code seems doesn't have problem. there seems to be no leak from dentry and mnt of path in first_first and find_next.
path_put(&(dir_fp->filp->f_path)); <--- this path_put for ksmbd_vfs_kern_path()
if (le16_to_cpu(req_params->SearchFlags) &
CIFS_SEARCH_CLOSE_AT_END)
ksmbd_close_fd(work, dir_fp->volatile_id); <-- ksmbd_close_fd->fput->dput(), mntput() of path for ksmbd_vfs_dentry_open()
@namjaejeon
I didn't realize ksmbd_close_fd() was indirectly calling path_put(). Disregard this patch as it is wrong.
Thanks for reviewing.
Error paths after ksmbd_vfs_dentry_open() were missing path_put() calls. Additionally, a path_put() is needed in the normal codepath.
'struct path' reference count is incremented twice in find_first():
One reference count must remain so that dir_fp is valid when it's looked up in find_next().
path_put() must be called once. It must be called a second time if: