mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 1/2] fs/exofs: fix potential memory leak in mount option parsing
@ 2018-06-13  4:05 Chengguang Xu
  2018-06-13  4:05 ` [PATCH 2/2] fs/exofs: only use true/false for asignment of bool type variable Chengguang Xu
  2018-06-21  2:14 ` [PATCH 1/2] fs/exofs: fix potential memory leak in mount option parsing cgxu519
  0 siblings, 2 replies; 3+ messages in thread
From: Chengguang Xu @ 2018-06-13  4:05 UTC (permalink / raw)
  To: ooo; +Cc: linux-kernel, Chengguang Xu

There are some cases can cause memory leak when parsing
option 'osdname'.

Signed-off-by: Chengguang Xu <cgxu519@gmx.com>
---
 fs/exofs/super.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/fs/exofs/super.c b/fs/exofs/super.c
index 719a315..f3e17a9 100644
--- a/fs/exofs/super.c
+++ b/fs/exofs/super.c
@@ -101,6 +101,7 @@ static int parse_options(char *options, struct exofs_mountopt *opts)
 		token = match_token(p, tokens, args);
 		switch (token) {
 		case Opt_name:
+			kfree(opts->dev_name);
 			opts->dev_name = match_strdup(&args[0]);
 			if (unlikely(!opts->dev_name)) {
 				EXOFS_ERR("Error allocating dev_name");
@@ -867,8 +868,10 @@ static struct dentry *exofs_mount(struct file_system_type *type,
 	int ret;
 
 	ret = parse_options(data, &opts);
-	if (ret)
+	if (ret) {
+		kfree(opts.dev_name);
 		return ERR_PTR(ret);
+	}
 
 	if (!opts.dev_name)
 		opts.dev_name = dev_name;
-- 
1.8.3.1


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

* [PATCH 2/2] fs/exofs: only use true/false for asignment of bool type variable
  2018-06-13  4:05 [PATCH 1/2] fs/exofs: fix potential memory leak in mount option parsing Chengguang Xu
@ 2018-06-13  4:05 ` Chengguang Xu
  2018-06-21  2:14 ` [PATCH 1/2] fs/exofs: fix potential memory leak in mount option parsing cgxu519
  1 sibling, 0 replies; 3+ messages in thread
From: Chengguang Xu @ 2018-06-13  4:05 UTC (permalink / raw)
  To: ooo; +Cc: linux-kernel, Chengguang Xu

Signed-off-by: Chengguang Xu <cgxu519@gmx.com>
---
 fs/exofs/super.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/exofs/super.c b/fs/exofs/super.c
index f3e17a9..75b5db0 100644
--- a/fs/exofs/super.c
+++ b/fs/exofs/super.c
@@ -118,7 +118,7 @@ static int parse_options(char *options, struct exofs_mountopt *opts)
 					  EXOFS_MIN_PID);
 				return -EINVAL;
 			}
-			s_pid = 1;
+			s_pid = true;
 			break;
 		case Opt_to:
 			if (match_int(&args[0], &option))
-- 
1.8.3.1


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

* Re: [PATCH 1/2] fs/exofs: fix potential memory leak in mount option parsing
  2018-06-13  4:05 [PATCH 1/2] fs/exofs: fix potential memory leak in mount option parsing Chengguang Xu
  2018-06-13  4:05 ` [PATCH 2/2] fs/exofs: only use true/false for asignment of bool type variable Chengguang Xu
@ 2018-06-21  2:14 ` cgxu519
  1 sibling, 0 replies; 3+ messages in thread
From: cgxu519 @ 2018-06-21  2:14 UTC (permalink / raw)
  To: ooo; +Cc: linux-kernel, cgxu519

Hi Boaz,

Could you have a look at this trivial patch?

Thanks,
Chengguang.

On 06/13/2018 12:05 PM, Chengguang Xu wrote:
> There are some cases can cause memory leak when parsing
> option 'osdname'.
>
> Signed-off-by: Chengguang Xu <cgxu519@gmx.com>
> ---
>   fs/exofs/super.c | 5 ++++-
>   1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/fs/exofs/super.c b/fs/exofs/super.c
> index 719a315..f3e17a9 100644
> --- a/fs/exofs/super.c
> +++ b/fs/exofs/super.c
> @@ -101,6 +101,7 @@ static int parse_options(char *options, struct exofs_mountopt *opts)
>   		token = match_token(p, tokens, args);
>   		switch (token) {
>   		case Opt_name:
> +			kfree(opts->dev_name);
>   			opts->dev_name = match_strdup(&args[0]);
>   			if (unlikely(!opts->dev_name)) {
>   				EXOFS_ERR("Error allocating dev_name");
> @@ -867,8 +868,10 @@ static struct dentry *exofs_mount(struct file_system_type *type,
>   	int ret;
>   
>   	ret = parse_options(data, &opts);
> -	if (ret)
> +	if (ret) {
> +		kfree(opts.dev_name);
>   		return ERR_PTR(ret);
> +	}
>   
>   	if (!opts.dev_name)
>   		opts.dev_name = dev_name;


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

end of thread, other threads:[~2018-06-21  2:14 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-13  4:05 [PATCH 1/2] fs/exofs: fix potential memory leak in mount option parsing Chengguang Xu
2018-06-13  4:05 ` [PATCH 2/2] fs/exofs: only use true/false for asignment of bool type variable Chengguang Xu
2018-06-21  2:14 ` [PATCH 1/2] fs/exofs: fix potential memory leak in mount option parsing cgxu519

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®