fs: reiserfs: free new_opts in reiserfs_remount
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.
--- fs/reiserfs/super.c | 1 + 1 file changed, 1 insertion(+)
fs/reiserfs/super.c +1 -0
@@ -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
Quoted 9 lines · Dongliang Mu
Since the commit
c3d98ea08291("VFS: Don't use save/replace_mount_options if not usinggeneric_show_options") eliminatesreplace_mount_optionsin reiserfs, but did not handle the allocatednew_opts,
it will cause memory leak in thereiserfs_remount.Fix this by freeing
new_optsin thereiserfs_remounttemporarily.Fixes c3d98ea08291 ("VFS: Don't use save/replace_mount_options if not using generic_show_options")Signed-off-by Dongliang Mu <[email protected]>
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@@ -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
Quoted 7 lines · Jan Kara
Quoted 5 lines · Dongliang Mu
Since the commit
c3d98ea08291("VFS: Don't use save/replace_mount_options if not usinggeneric_show_options") eliminatesreplace_mount_optionsin reiserfs, but did not handle the allocatednew_opts,
it will cause memory leak in thereiserfs_remount.
Quoted 8 lines
Quoted 4 lines
Fix this by freeing
new_optsin thereiserfs_remounttemporarily.Fixes c3d98ea08291 ("VFS: Don't use save/replace_mount_options if not using generic_show_options")Signed-off-by Dongliang Mu <[email protected]>Thanks for the patch but I can see that
new_optsis not actually used at all inreiserfs_remount()so we should perhaps just remove them (includingkstrdup()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@@ -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
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 usinggeneric_show_options") eliminatesreplace_mount_optionsin reiserfs, but did not handle the allocatednew_opts,
it will cause memory leak in thereiserfs_remount.Quoted 8 lines
Quoted 4 lines
Fix this by freeing
new_optsin thereiserfs_remounttemporarily.Fixes c3d98ea08291 ("VFS: Don't use save/replace_mount_options if not using generic_show_options")Signed-off-by Dongliang Mu <[email protected]>Thanks for the patch but I can see that
new_optsis not actually used at all inreiserfs_remount()so we should perhaps just remove them (includingkstrdup()et al).
Quoted 6 lines
That's also a plan. Since I am not sure if maintainers will use
new_optsanymore, So I propose a temporary patch to fix this memory leak.If you think
new_optsis not used anymore, let's remove all the code related tonew_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
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 usinggeneric_show_options") eliminatesreplace_mount_optionsin reiserfs, but did not handle the allocatednew_opts,
it will cause memory leak in thereiserfs_remount.Fix this by freeing
new_optsin thereiserfs_remounttemporarily.Fixes c3d98ea08291 ("VFS: Don't use save/replace_mount_options if not using generic_show_options")Signed-off-by Dongliang Mu <[email protected]>Thanks for the patch but I can see that
new_optsis not actually used at all inreiserfs_remount()so we should perhaps just remove them (includingkstrdup()et al).
Quoted 8 lines
Quoted 6 lines
That's also a plan. Since I am not sure if maintainers will use
new_optsanymore, So I propose a temporary patch to fix this memory leak.If you think
new_optsis not used anymore, let's remove all the code related tonew_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