diff mbox series

[v3] fs: affs: fix a memory leak in affs_remount

Message ID 20191002215242.14317-1-navid.emamdoost@gmail.com (mailing list archive)
State New, archived
Headers show
Series [v3] fs: affs: fix a memory leak in affs_remount | expand

Commit Message

Navid Emamdoost Oct. 2, 2019, 9:52 p.m. UTC
In affs_remount if data is provided it is duplicated into new_opts.
The allocated memory for new_opts is only released if pare_options fail.
But the variable is not used anywhere. So the new_opts should be
removed.

Fixes: c8f33d0bec99 ("affs: kstrdup() memory handling")
Signed-off-by: Navid Emamdoost <navid.emamdoost@gmail.com>
---
Changes in v2:
	-- fix typo
Changes in v3:
	-- remove the call to kstrdup, as new_opts is not used anymore.
---
 fs/affs/super.c | 5 -----
 1 file changed, 5 deletions(-)

Comments

David Sterba Oct. 30, 2019, 11:44 a.m. UTC | #1
On Wed, Oct 02, 2019 at 04:52:37PM -0500, Navid Emamdoost wrote:
> In affs_remount if data is provided it is duplicated into new_opts.
> The allocated memory for new_opts is only released if pare_options fail.
> But the variable is not used anywhere. So the new_opts should be
> removed.
> 
> Fixes: c8f33d0bec99 ("affs: kstrdup() memory handling")
> Signed-off-by: Navid Emamdoost <navid.emamdoost@gmail.com>
> ---
> Changes in v2:
> 	-- fix typo
> Changes in v3:
> 	-- remove the call to kstrdup, as new_opts is not used anymore.

Added it to affs queue. There are still typos in the changelog and this
was pointed out, and v3 lacks the explanations I replied to v2.  I'll
fix it up.
diff mbox series

Patch

diff --git a/fs/affs/super.c b/fs/affs/super.c
index cc463ae47c12..b6c6080d186c 100644
--- a/fs/affs/super.c
+++ b/fs/affs/super.c
@@ -565,10 +565,6 @@  affs_remount(struct super_block *sb, int *flags, char *data)
 	char			 volume[32];
 	char			*prefix = NULL;
 
-	new_opts = kstrdup(data, GFP_KERNEL);
-	if (data && !new_opts)
-		return -ENOMEM;
-
 	pr_debug("%s(flags=0x%x,opts=\"%s\")\n", __func__, *flags, data);
 
 	sync_filesystem(sb);
@@ -579,7 +575,6 @@  affs_remount(struct super_block *sb, int *flags, char *data)
 			   &blocksize, &prefix, volume,
 			   &mount_flags)) {
 		kfree(prefix);
-		kfree(new_opts);
 		return -EINVAL;
 	}