2018-05-22 04:26:47

by Chengguang Xu

[permalink] [raw]
Subject: [PATCH] fs/affs: fix potential memory leak in option parsing

When specifying option 'prefix' multiple times,
current option parsing will cause memory leak.
Hence, call kfree for previous one in this case.

Signed-off-by: Chengguang Xu <[email protected]>
---
fs/affs/super.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/fs/affs/super.c b/fs/affs/super.c
index e602619..d1ad11a 100644
--- a/fs/affs/super.c
+++ b/fs/affs/super.c
@@ -241,6 +241,7 @@ enum {
affs_set_opt(*mount_opts, SF_NO_TRUNCATE);
break;
case Opt_prefix:
+ kfree(*prefix);
*prefix = match_strdup(&args[0]);
if (!*prefix)
return 0;
--
1.8.3.1



2018-05-28 16:15:35

by David Sterba

[permalink] [raw]
Subject: Re: [PATCH] fs/affs: fix potential memory leak in option parsing

On Tue, May 22, 2018 at 12:24:25PM +0800, Chengguang Xu wrote:
> When specifying option 'prefix' multiple times,
> current option parsing will cause memory leak.
> Hence, call kfree for previous one in this case.
>
> Signed-off-by: Chengguang Xu <[email protected]>

Thanks, the patch and others that may queue up will be in my git tree
git://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux.git in a
branch with 'affs' somewhere in the name.