linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ext4: fix possible memory leak in ext4_remount()
@ 2013-02-27  5:18 Wei Yongjun
  2013-02-27 12:45 ` Lukáš Czerner
  2013-03-02 22:13 ` Theodore Ts'o
  0 siblings, 2 replies; 3+ messages in thread
From: Wei Yongjun @ 2013-02-27  5:18 UTC (permalink / raw)
  To: tytso, adilger.kernel; +Cc: yongjun_wei, linux-ext4

From: Wei Yongjun <yongjun_wei@trendmicro.com.cn>

'orig_data' is malloced in ext4_remount() and should be freed
before leaving from the error handling cases, otherwise it will
cause memory leak.

Signed-off-by: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
---
 fs/ext4/super.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index 373d46c..8ae09e3 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -4538,6 +4538,7 @@ static int ext4_remount(struct super_block *sb, int *flags, char *data)
 			if (!old_opts.s_qf_names[i]) {
 				for (j = 0; j < i; j++)
 					kfree(old_opts.s_qf_names[j]);
+				kfree(orig_data);
 				return -ENOMEM;
 			}
 		} else



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] ext4: fix possible memory leak in ext4_remount()
  2013-02-27  5:18 [PATCH] ext4: fix possible memory leak in ext4_remount() Wei Yongjun
@ 2013-02-27 12:45 ` Lukáš Czerner
  2013-03-02 22:13 ` Theodore Ts'o
  1 sibling, 0 replies; 3+ messages in thread
From: Lukáš Czerner @ 2013-02-27 12:45 UTC (permalink / raw)
  To: Wei Yongjun; +Cc: tytso, adilger.kernel, yongjun_wei, linux-ext4

On Wed, 27 Feb 2013, Wei Yongjun wrote:

> Date: Wed, 27 Feb 2013 13:18:53 +0800
> From: Wei Yongjun <weiyj.lk@gmail.com>
> To: tytso@mit.edu, adilger.kernel@dilger.ca
> Cc: yongjun_wei@trendmicro.com.cn, linux-ext4@vger.kernel.org
> Subject: [PATCH] ext4: fix possible memory leak in ext4_remount()
> 
> From: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
> 
> 'orig_data' is malloced in ext4_remount() and should be freed
> before leaving from the error handling cases, otherwise it will
> cause memory leak.

Good catch, thanks!

Reviewed-by: Lukas Czerner <lczerner@redhat.com>

> 
> Signed-off-by: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
> ---
>  fs/ext4/super.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/fs/ext4/super.c b/fs/ext4/super.c
> index 373d46c..8ae09e3 100644
> --- a/fs/ext4/super.c
> +++ b/fs/ext4/super.c
> @@ -4538,6 +4538,7 @@ static int ext4_remount(struct super_block *sb, int *flags, char *data)
>  			if (!old_opts.s_qf_names[i]) {
>  				for (j = 0; j < i; j++)
>  					kfree(old_opts.s_qf_names[j]);
> +				kfree(orig_data);
>  				return -ENOMEM;
>  			}
>  		} else
> 
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] ext4: fix possible memory leak in ext4_remount()
  2013-02-27  5:18 [PATCH] ext4: fix possible memory leak in ext4_remount() Wei Yongjun
  2013-02-27 12:45 ` Lukáš Czerner
@ 2013-03-02 22:13 ` Theodore Ts'o
  1 sibling, 0 replies; 3+ messages in thread
From: Theodore Ts'o @ 2013-03-02 22:13 UTC (permalink / raw)
  To: Wei Yongjun; +Cc: adilger.kernel, yongjun_wei, linux-ext4

On Wed, Feb 27, 2013 at 01:18:53PM +0800, Wei Yongjun wrote:
> From: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
> 
> 'orig_data' is malloced in ext4_remount() and should be freed
> before leaving from the error handling cases, otherwise it will
> cause memory leak.
> 
> Signed-off-by: Wei Yongjun <yongjun_wei@trendmicro.com.cn>

Thanks, applied.

					- Ted

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2013-03-02 22:13 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-02-27  5:18 [PATCH] ext4: fix possible memory leak in ext4_remount() Wei Yongjun
2013-02-27 12:45 ` Lukáš Czerner
2013-03-02 22:13 ` Theodore Ts'o

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).