All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] pstore/platform: fix potential mem leak if pstore_init_fs failed
@ 2020-02-07  9:46 qiwuchen55
  2020-02-07  9:46 ` [PATCH 2/2] pstore/ram: remove unnecessary ramoops_unregister_dummy() qiwuchen55
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: qiwuchen55 @ 2020-02-07  9:46 UTC (permalink / raw)
  To: keescook, anton, ccross, tony.luck; +Cc: linux-fsdevel, chenqiwu

From: chenqiwu <chenqiwu@xiaomi.com>

There is a potential mem leak when pstore_init_fs failed,
since the pstore compression maybe unlikey to initialized
successfully. We must clean up the allocation once this
unlikey issue happens.

Signed-off-by: chenqiwu <chenqiwu@xiaomi.com>
---
 fs/pstore/platform.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/fs/pstore/platform.c b/fs/pstore/platform.c
index d896457..114dbdf15 100644
--- a/fs/pstore/platform.c
+++ b/fs/pstore/platform.c
@@ -822,10 +822,10 @@ static int __init pstore_init(void)
 	allocate_buf_for_compression();
 
 	ret = pstore_init_fs();
-	if (ret)
-		return ret;
+	if (ret < 0)
+		free_buf_for_compression();
 
-	return 0;
+	return ret;
 }
 late_initcall(pstore_init);
 
-- 
1.9.1


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

* [PATCH 2/2] pstore/ram: remove unnecessary ramoops_unregister_dummy()
  2020-02-07  9:46 [PATCH 1/2] pstore/platform: fix potential mem leak if pstore_init_fs failed qiwuchen55
@ 2020-02-07  9:46 ` qiwuchen55
  2020-02-25 19:16   ` Kees Cook
  2020-02-14  1:57 ` [PATCH 1/2] pstore/platform: fix potential mem leak if pstore_init_fs failed chenqiwu
  2020-02-25 19:13 ` Kees Cook
  2 siblings, 1 reply; 6+ messages in thread
From: qiwuchen55 @ 2020-02-07  9:46 UTC (permalink / raw)
  To: keescook, anton, ccross, tony.luck; +Cc: linux-fsdevel, chenqiwu

From: chenqiwu <chenqiwu@xiaomi.com>

Remove unnecessary ramoops_unregister_dummy() if ramoops
platform device register failed.

Signed-off-by: chenqiwu <chenqiwu@xiaomi.com>
---
 fs/pstore/ram.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/fs/pstore/ram.c b/fs/pstore/ram.c
index 013486b..7956221 100644
--- a/fs/pstore/ram.c
+++ b/fs/pstore/ram.c
@@ -963,7 +963,6 @@ static void __init ramoops_register_dummy(void)
 		pr_info("could not create platform device: %ld\n",
 			PTR_ERR(dummy));
 		dummy = NULL;
-		ramoops_unregister_dummy();
 	}
 }
 
-- 
1.9.1


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

* Re: [PATCH 1/2] pstore/platform: fix potential mem leak if pstore_init_fs failed
  2020-02-07  9:46 [PATCH 1/2] pstore/platform: fix potential mem leak if pstore_init_fs failed qiwuchen55
  2020-02-07  9:46 ` [PATCH 2/2] pstore/ram: remove unnecessary ramoops_unregister_dummy() qiwuchen55
@ 2020-02-14  1:57 ` chenqiwu
  2020-02-25 19:13 ` Kees Cook
  2 siblings, 0 replies; 6+ messages in thread
From: chenqiwu @ 2020-02-14  1:57 UTC (permalink / raw)
  To: keescook, anton, ccross, tony.luck; +Cc: linux-fsdevel, chenqiwu

On Fri, Feb 07, 2020 at 05:46:39PM +0800, qiwuchen55@gmail.com wrote:
> From: chenqiwu <chenqiwu@xiaomi.com>
> 
> There is a potential mem leak when pstore_init_fs failed,
> since the pstore compression maybe unlikey to initialized
> successfully. We must clean up the allocation once this
> unlikey issue happens.
> 
> Signed-off-by: chenqiwu <chenqiwu@xiaomi.com>
> ---
>  fs/pstore/platform.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/fs/pstore/platform.c b/fs/pstore/platform.c
> index d896457..114dbdf15 100644
> --- a/fs/pstore/platform.c
> +++ b/fs/pstore/platform.c
> @@ -822,10 +822,10 @@ static int __init pstore_init(void)
>  	allocate_buf_for_compression();
>  
>  	ret = pstore_init_fs();
> -	if (ret)
> -		return ret;
> +	if (ret < 0)
> +		free_buf_for_compression();
>  
> -	return 0;
> +	return ret;
>  }
>  late_initcall(pstore_init);
>
Deal all,
Any update about two fixes?

BRs,
Qiwu

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

* Re: [PATCH 1/2] pstore/platform: fix potential mem leak if pstore_init_fs failed
  2020-02-07  9:46 [PATCH 1/2] pstore/platform: fix potential mem leak if pstore_init_fs failed qiwuchen55
  2020-02-07  9:46 ` [PATCH 2/2] pstore/ram: remove unnecessary ramoops_unregister_dummy() qiwuchen55
  2020-02-14  1:57 ` [PATCH 1/2] pstore/platform: fix potential mem leak if pstore_init_fs failed chenqiwu
@ 2020-02-25 19:13 ` Kees Cook
  2 siblings, 0 replies; 6+ messages in thread
From: Kees Cook @ 2020-02-25 19:13 UTC (permalink / raw)
  To: qiwuchen55; +Cc: anton, ccross, tony.luck, linux-fsdevel, chenqiwu

On Fri, Feb 07, 2020 at 05:46:39PM +0800, qiwuchen55@gmail.com wrote:
> From: chenqiwu <chenqiwu@xiaomi.com>
> 
> There is a potential mem leak when pstore_init_fs failed,
> since the pstore compression maybe unlikey to initialized
> successfully. We must clean up the allocation once this
> unlikey issue happens.
> 
> Signed-off-by: chenqiwu <chenqiwu@xiaomi.com>

Thanks! Applied to for-next/pstore.

-Kees

> ---
>  fs/pstore/platform.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/fs/pstore/platform.c b/fs/pstore/platform.c
> index d896457..114dbdf15 100644
> --- a/fs/pstore/platform.c
> +++ b/fs/pstore/platform.c
> @@ -822,10 +822,10 @@ static int __init pstore_init(void)
>  	allocate_buf_for_compression();
>  
>  	ret = pstore_init_fs();
> -	if (ret)
> -		return ret;
> +	if (ret < 0)
> +		free_buf_for_compression();
>  
> -	return 0;
> +	return ret;
>  }
>  late_initcall(pstore_init);
>  
> -- 
> 1.9.1
> 

-- 
Kees Cook

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

* Re: [PATCH 2/2] pstore/ram: remove unnecessary ramoops_unregister_dummy()
  2020-02-07  9:46 ` [PATCH 2/2] pstore/ram: remove unnecessary ramoops_unregister_dummy() qiwuchen55
@ 2020-02-25 19:16   ` Kees Cook
  0 siblings, 0 replies; 6+ messages in thread
From: Kees Cook @ 2020-02-25 19:16 UTC (permalink / raw)
  To: qiwuchen55; +Cc: anton, ccross, tony.luck, linux-fsdevel, chenqiwu

On Fri, Feb 07, 2020 at 05:46:40PM +0800, qiwuchen55@gmail.com wrote:
> From: chenqiwu <chenqiwu@xiaomi.com>
> 
> Remove unnecessary ramoops_unregister_dummy() if ramoops
> platform device register failed.
> 
> Signed-off-by: chenqiwu <chenqiwu@xiaomi.com>

Thanks! Applied to for-next/pstore.

-Kees

> ---
>  fs/pstore/ram.c | 1 -
>  1 file changed, 1 deletion(-)
> 
> diff --git a/fs/pstore/ram.c b/fs/pstore/ram.c
> index 013486b..7956221 100644
> --- a/fs/pstore/ram.c
> +++ b/fs/pstore/ram.c
> @@ -963,7 +963,6 @@ static void __init ramoops_register_dummy(void)
>  		pr_info("could not create platform device: %ld\n",
>  			PTR_ERR(dummy));
>  		dummy = NULL;
> -		ramoops_unregister_dummy();
>  	}
>  }
>  
> -- 
> 1.9.1
> 

-- 
Kees Cook

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

* [PATCH 2/2] pstore/ram: remove unnecessary ramoops_unregister_dummy()
  2020-02-04 13:07 qiwuchen55
@ 2020-02-04 13:07 ` qiwuchen55
  0 siblings, 0 replies; 6+ messages in thread
From: qiwuchen55 @ 2020-02-04 13:07 UTC (permalink / raw)
  To: keescook, anton, ccross, tony.luck; +Cc: linux-kernel, chenqiwu

From: chenqiwu <chenqiwu@xiaomi.com>

Remove unnecessary ramoops_unregister_dummy() if ramoops
platform device register failed.

Signed-off-by: chenqiwu <chenqiwu@xiaomi.com>
---
 fs/pstore/ram.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/fs/pstore/ram.c b/fs/pstore/ram.c
index 013486b..7956221 100644
--- a/fs/pstore/ram.c
+++ b/fs/pstore/ram.c
@@ -963,7 +963,6 @@ static void __init ramoops_register_dummy(void)
 		pr_info("could not create platform device: %ld\n",
 			PTR_ERR(dummy));
 		dummy = NULL;
-		ramoops_unregister_dummy();
 	}
 }
 
-- 
1.9.1


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

end of thread, other threads:[~2020-02-25 19:16 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-07  9:46 [PATCH 1/2] pstore/platform: fix potential mem leak if pstore_init_fs failed qiwuchen55
2020-02-07  9:46 ` [PATCH 2/2] pstore/ram: remove unnecessary ramoops_unregister_dummy() qiwuchen55
2020-02-25 19:16   ` Kees Cook
2020-02-14  1:57 ` [PATCH 1/2] pstore/platform: fix potential mem leak if pstore_init_fs failed chenqiwu
2020-02-25 19:13 ` Kees Cook
  -- strict thread matches above, loose matches on Subject: below --
2020-02-04 13:07 qiwuchen55
2020-02-04 13:07 ` [PATCH 2/2] pstore/ram: remove unnecessary ramoops_unregister_dummy() qiwuchen55

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.