Skip to contentSkip to conversation

fs: reiserfs: free new_opts in reiserfs_remount

PATCH In review Dongliang Mu 2 participants 5 messages Oct 27, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fs: reiserfs: free new_opts in reiserfs_remount

Since the commit c3d98ea08291 ("VFS: Don't use save/replace_mount_options if not using generic_show_options") eliminates replace_mount_options in reiserfs, but did not handle the allocated new_opts,
it will cause memory leak in the reiserfs_remount.

Fix this by freeing new_opts in the reiserfs_remount temporarily.

Fixes c3d98ea08291 ("VFS: Don't use save/replace_mount_options if not using generic_show_options")
---
 fs/reiserfs/super.c | 1 +
 1 file changed, 1 insertion(+)
fs/reiserfs/super.c +1 -0
index 58481f8d63d5..b36865c8b66a 100644
@@ -1594,6 +1594,7 @@ static int reiserfs_remount(struct super_block *s, int *mount_flags, char *arg)
 	}
 
 out_ok_unlocked:
+	kfree(new_opts);
 	return 0;
 
 out_err_unlock:
Signature · 1 line
2.25.1
#1 lore raw
Quoted 9 lines · Dongliang Mu

Since the commit c3d98ea08291 ("VFS: Don't use save/replace_mount_options if not using generic_show_options") eliminates replace_mount_options in reiserfs, but did not handle the allocated new_opts,
it will cause memory leak in the reiserfs_remount.

Fix this by freeing new_opts in the reiserfs_remount temporarily.

Fixes c3d98ea08291 ("VFS: Don't use save/replace_mount_options if not using generic_show_options")

Thanks for the patch but I can see that new_opts is not actually used at all in reiserfs_remount() so we should perhaps just remove them (including kstrdup() et al).

Honza

Quoted 19 lines
---
 fs/reiserfs/super.c | 1 +
 1 file changed, 1 insertion(+)
fs/reiserfs/super.c +1 -0
index 58481f8d63d5..b36865c8b66a 100644
@@ -1594,6 +1594,7 @@ static int reiserfs_remount(struct super_block *s, int *mount_flags, char *arg)
 	}
 
 out_ok_unlocked:
+	kfree(new_opts);
 	return 0;
 
 out_err_unlock:
Signature · 1 line
2.25.1
Signature · 2 lines
Jan Kara <[email protected]>
SUSE Labs, CR
#2 lore raw
Quoted 7 lines · Jan Kara
Quoted 5 lines · Dongliang Mu

Since the commit c3d98ea08291 ("VFS: Don't use save/replace_mount_options if not using generic_show_options") eliminates replace_mount_options in reiserfs, but did not handle the allocated new_opts,
it will cause memory leak in the reiserfs_remount.

Quoted 8 lines
Quoted 4 lines

Fix this by freeing new_opts in the reiserfs_remount temporarily.

Fixes c3d98ea08291 ("VFS: Don't use save/replace_mount_options if not using generic_show_options")

Thanks for the patch but I can see that new_opts is not actually used at all in reiserfs_remount() so we should perhaps just remove them (including kstrdup() et al).

That's also a plan. Since I am not sure if maintainers will use new_opts anymore, So I propose a temporary patch to fix this memory leak.

If you think new_opts is not used anymore, let's remove all the code related to new_opts.

Quoted 25 lines

Honza

Quoted 17 lines
---
 fs/reiserfs/super.c | 1 +
 1 file changed, 1 insertion(+)
fs/reiserfs/super.c +1 -1
index 58481f8d63d5..b36865c8b66a 100644
@@ -1594,6 +1594,7 @@ static int reiserfs_remount(struct super_block *s, int *mount_flags, char *arg)
      }
 
 out_ok_unlocked:
+     kfree(new_opts);
      return 0;
 
 out_err_unlock:
--
Quoted 2 lines

2.25.1

--
Jan Kara <[email protected]>
SUSE Labs, CR

#3 lore raw
Quoted 17 lines · Dongliang Mu
Quoted 7 lines · Jan Kara
Quoted 5 lines · Dongliang Mu

Since the commit c3d98ea08291 ("VFS: Don't use save/replace_mount_options if not using generic_show_options") eliminates replace_mount_options in reiserfs, but did not handle the allocated new_opts,
it will cause memory leak in the reiserfs_remount.

Quoted 8 lines
Quoted 4 lines

Fix this by freeing new_opts in the reiserfs_remount temporarily.

Fixes c3d98ea08291 ("VFS: Don't use save/replace_mount_options if not using generic_show_options")

Thanks for the patch but I can see that new_opts is not actually used at all in reiserfs_remount() so we should perhaps just remove them (including kstrdup() et al).

Quoted 6 lines

That's also a plan. Since I am not sure if maintainers will use new_opts anymore, So I propose a temporary patch to fix this memory leak.

If you think new_opts is not used anymore, let's remove all the code related to new_opts.

If it is ever needed again, we can always add it. Please just remove it. Thanks!

Honza

Signature · 2 lines
Jan Kara <[email protected]>
SUSE Labs, CR
#4 lore raw
Quoted 19 lines · Jan Kara
Quoted 17 lines · Dongliang Mu
Quoted 15 lines · Jan Kara
Quoted 9 lines · Dongliang Mu

Since the commit c3d98ea08291 ("VFS: Don't use save/replace_mount_options if not using generic_show_options") eliminates replace_mount_options in reiserfs, but did not handle the allocated new_opts,
it will cause memory leak in the reiserfs_remount.

Fix this by freeing new_opts in the reiserfs_remount temporarily.

Fixes c3d98ea08291 ("VFS: Don't use save/replace_mount_options if not using generic_show_options")

Thanks for the patch but I can see that new_opts is not actually used at all in reiserfs_remount() so we should perhaps just remove them (including kstrdup() et al).

Quoted 8 lines
Quoted 6 lines

That's also a plan. Since I am not sure if maintainers will use new_opts anymore, So I propose a temporary patch to fix this memory leak.

If you think new_opts is not used anymore, let's remove all the code related to new_opts.

If it is ever needed again, we can always add it. Please just remove it.

Sure. I will send a patch v2.

Quoted 6 lines

Thanks!

Honza
--
Jan Kara <[email protected]>
SUSE Labs, CR