From patchwork Thu Apr 16 13:22:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 227703 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 D9AB7C2BB55 for ; Thu, 16 Apr 2020 15:03:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B914A20771 for ; Thu, 16 Apr 2020 15:03:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1587049392; bh=otK5x4Ls3x9usVl63svp8ToBMJhcukjNtYux7ORX/Ps=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=mgMy7BL136jz1wNQPTVE0CV0khkFcZRU/SoQPogYnP24vPPVOJU1BMxinB77O2FMn ZxEiYsxSh9EQFnxkD9eFGpeU3u/RHbhc2IFSHeRsJjDGFzf5Fg6E9KCbdBKyGd2Zvl fK0bSvoVLVdD/8xvMrI+CwCkxou75WaPuM71MiE8= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2405118AbgDPPDL (ORCPT ); Thu, 16 Apr 2020 11:03:11 -0400 Received: from mail.kernel.org ([198.145.29.99]:40090 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2636240AbgDPNxi (ORCPT ); Thu, 16 Apr 2020 09:53:38 -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 0394320732; Thu, 16 Apr 2020 13:53:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1587045217; bh=otK5x4Ls3x9usVl63svp8ToBMJhcukjNtYux7ORX/Ps=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WXvLj2p62U9GT/9nhMLM2FFxGL9C3sp9GfqpR7DNB6pIVIun1SxwCdMsVBpmcrcNK oRyGDORidU4B5+8YIALngH6drucfUlzQnLRQWMgRkfjvT1GwcPry0SgOGy3IUOpiVp UGN9+kG4csMnmSFZ8f4i4ot20smS76fRMfDXf48A= 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.6 043/254] pstore/platform: fix potential mem leak if pstore_init_fs failed Date: Thu, 16 Apr 2020 15:22:12 +0200 Message-Id: <20200416131331.267012318@linuxfoundation.org> X-Mailer: git-send-email 2.26.1 In-Reply-To: <20200416131325.804095985@linuxfoundation.org> References: <20200416131325.804095985@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 d896457e7c117..408277ee3cdb9 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);