Skip to contentSkip to conversation

fs/ntfs3: fix ntfs_fnd leak when compare function is missing

PATCH In review [email protected] 2 participants 2 messages Jul 29 – Oct 13 NTFS3 filesystem

lore
Share & tools
lore
#0 lore raw

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")
---
 fs/ntfs3/index.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
fs/ntfs3/index.c +6 -3
index 2b439ac04356..8e3cf28b5257 100644
@@ -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
#1 lore raw
Quoted 49 lines · On 7/29/26 08:49, [email protected] wrote:

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")
---
  fs/ntfs3/index.c | 9 ++++++---
  1 file changed, 6 insertions(+), 3 deletions(-)
fs/ntfs3/index.c +6 -4
index 2b439ac04356..8e3cf28b5257 100644
@@ -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