diff mbox series

[1/2] pstore/platform: fix potential mem leak if pstore_init_fs failed

Message ID 1581068800-13817-1-git-send-email-qiwuchen55@gmail.com (mailing list archive)
State New, archived
Headers show
Series [1/2] pstore/platform: fix potential mem leak if pstore_init_fs failed | expand

Commit Message

chenqiwu Feb. 7, 2020, 9:46 a.m. UTC
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(-)

Comments

chenqiwu Feb. 14, 2020, 1:57 a.m. UTC | #1
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
Kees Cook Feb. 25, 2020, 7:13 p.m. UTC | #2
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
>
diff mbox series

Patch

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);