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 1/2] pstore/platform: fix potential mem leak if pstore_init_fs failed
@ 2020-02-04 13:07 qiwuchen55
  2020-02-04 13:07 ` [PATCH 2/2] pstore/ram: remove unnecessary ramoops_unregister_dummy() qiwuchen55
  0 siblings, 1 reply; 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>

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

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.