From patchwork Thu Apr 16 13:22:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 227645 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 558C3C2BB55 for ; Thu, 16 Apr 2020 15:22:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 32937214D8 for ; Thu, 16 Apr 2020 15:22:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1587050547; bh=NupKDHaU0vDTr4mFGVn6du0MAD0o5CYqbcBOyesCm5o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=zB7KEofU8fWTkAxYDXKyzw1XoPbZbPIBd0+3EEEYNaxephCLWyO/YrQTGJb8gKRSv f7MADyVa2zQCKMoviXv8R9UPSlKX6o4Rr1snAPJ1sde8OfjCV3Gg43HdehnDKhZtZk U0ulCogQCt07LG6Fi+XVYv0X+E5Z91b0iy7Wp1WQ= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2395142AbgDPPWR (ORCPT ); Thu, 16 Apr 2020 11:22:17 -0400 Received: from mail.kernel.org ([198.145.29.99]:59700 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2898550AbgDPNp6 (ORCPT ); Thu, 16 Apr 2020 09:45:58 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 0A2BB2223E; Thu, 16 Apr 2020 13:45:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1587044757; bh=NupKDHaU0vDTr4mFGVn6du0MAD0o5CYqbcBOyesCm5o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LHRRPhYe1RWt+BS8kZT0NHryawzJeufngnLiVikdxMA78fy66YVOCbVGH+IlzwYmL YI/n9Ufk7QZm32CR1rWJmeoihvniS+Pl44ujHRlp6GwxV7LbzywxGaBu/jib9pc/wp hUvcxrxHiBJZ4x9DkkQ97e7Ee2IrWV/KT/xo+/i0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, chenqiwu , Kees Cook , Sasha Levin Subject: [PATCH 5.4 049/232] pstore/platform: fix potential mem leak if pstore_init_fs failed Date: Thu, 16 Apr 2020 15:22:23 +0200 Message-Id: <20200416131321.862555251@linuxfoundation.org> X-Mailer: git-send-email 2.26.1 In-Reply-To: <20200416131316.640996080@linuxfoundation.org> References: <20200416131316.640996080@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: chenqiwu [ 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 Link: https://lore.kernel.org/r/1581068800-13817-1-git-send-email-qiwuchen55@gmail.com Signed-off-by: Kees Cook Signed-off-by: Sasha Levin --- fs/pstore/platform.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/pstore/platform.c b/fs/pstore/platform.c index 3d7024662d295..cdf5b8ae2583c 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);