]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
pstore/platform: fix potential mem leak if pstore_init_fs failed
authorchenqiwu <chenqiwu@xiaomi.com>
Fri, 7 Feb 2020 09:46:39 +0000 (17:46 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 17 Apr 2020 08:48:40 +0000 (10:48 +0200)
[ Upstream commit 8a57d6d4ddfa41c49014e20493152c41a38fcbf8 ]

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: Sasha Levin <sashal@kernel.org>
fs/pstore/platform.c

index 4bae3f4fe829dbb64810be3ccb148eb4d8b40dcb..dcd9c3163587c120b6f9fc57add528f0d3d2f88f 100644 (file)
@@ -802,9 +802,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);