fs/ntfs3: fix ntfs_fnd leak when compare function is missing
PATCH 1/1 fs/ntfs3: fix ntfs_fnd leak when compare function is missing
From: liyouhong <[email protected]>
indx_insert_entry(), indx_delete_entry() and indx_update_dup() take a finder via fnd_get() before calling get_cmp_func(). If no compare function is available they return -EINVAL and never release the finder.
Jump to the existing out path so fnd_put() still runs.
Fixes 3a2141b2f1c3 ("fs/ntfs3: resolve compare function in public index APIs")
Signed-off-by liyouhong <[email protected]>
--- fs/ntfs3/index.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
fs/ntfs3/index.c +6 -3
@@ -2048,7 +2048,8 @@ int indx_insert_entry(struct ntfs_index *indx, struct ntfs_inode *ni, cmp =get_cmp_func (root);if (unlikely (!cmp)) {WARN_ON_ONCE (1 ); -return -EINVAL ; + err = -EINVAL ; + goto out; }if (fnd_is_empty (fnd)) {
@@ -2406,7 +2407,8 @@ int indx_delete_entry(struct ntfs_index *indx, struct ntfs_inode *ni, cmp =get_cmp_func (root);if (unlikely (!cmp)) {WARN_ON_ONCE (1 ); -return -EINVAL ; + err = -EINVAL ; + goto out; }/* Locate the entry to remove. */
@@ -2787,7 +2789,8 @@ int indx_update_dup(struct ntfs_inode *ni, struct ntfs_sb_info *sbi, cmp =get_cmp_func (root);if (unlikely (!cmp)) {WARN_ON_ONCE (1 ); -return -EINVAL ; + err = -EINVAL ; + goto out; }/* Find entry in directory. */
Signature · 1 line
2.25.1
Konstantin Komarov
maintainerQuoted 49 lines · On 7/29/26 08:49, [email protected] wrote:
From: liyouhong <[email protected]>
indx_insert_entry(),indx_delete_entry()andindx_update_dup()take a finder viafnd_get()before callingget_cmp_func(). If no compare function is available they return-EINVALand never release the finder.Jump to the existing out path so
fnd_put()still runs.Fixes 3a2141b2f1c3 ("fs/ntfs3: resolve compare function in public index APIs")Signed-off-by liyouhong <[email protected]>--- fs/ntfs3/index.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)fs/ntfs3/index.c +6
-4@@ -2048,7 +2048,8 @@ int indx_insert_entry(struct ntfs_index *indx, struct ntfs_inode *ni, cmp =get_cmp_func (root);if (unlikely (!cmp)) {WARN_ON_ONCE (1 ); -return -EINVAL ; + err = -EINVAL ; + goto out; }if (fnd_is_empty (fnd)) {@@ -2406,7 +2407,8 @@ int indx_delete_entry(struct ntfs_index *indx, struct ntfs_inode *ni, cmp =get_cmp_func (root);if (unlikely (!cmp)) {WARN_ON_ONCE (1 ); -return -EINVAL ; + err = -EINVAL ; + goto out; }/* Locate the entry to remove. */ @@ -2787,7 +2789,8 @@ int indx_update_dup(struct ntfs_inode *ni, struct ntfs_sb_info *sbi, cmp =get_cmp_func (root);if (unlikely (!cmp)) {WARN_ON_ONCE (1 ); -return -EINVAL ; + err = -EINVAL ; + goto out; }/* Find entry in directory. */ --
Quoted 1 line
2.25.1
Hello,
Sorry for the delay.
Your patch was applied, thank you.
Regards,
Konstantin