blob: e1ccf8d9b57670d4c3c1bafa3994108b43d371f8 [file] [log] [blame]
From 5dbba61099c0cb062443bc75f8d72da85a8d56b6 Mon Sep 17 00:00:00 2001
From: chenqiwu <chenqiwu@xiaomi.com>
Date: Fri, 7 Feb 2020 17:46:39 +0800
Subject: [PATCH] pstore/platform: fix potential mem leak if pstore_init_fs
failed
commit 8a57d6d4ddfa41c49014e20493152c41a38fcbf8 upstream.
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>
Link: https://lore.kernel.org/r/1581068800-13817-1-git-send-email-qiwuchen55@gmail.com
Signed-off-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
diff --git a/fs/pstore/platform.c b/fs/pstore/platform.c
index 3d7024662d29..cdf5b8ae2583 100644
--- a/fs/pstore/platform.c
+++ b/fs/pstore/platform.c
@@ -823,9 +823,9 @@ static int __init pstore_init(void)
ret = pstore_init_fs();
if (ret)
- return ret;
+ free_buf_for_compression();
- return 0;
+ return ret;
}
late_initcall(pstore_init);
--
2.7.4