From mboxrd@z Thu Jan 1 00:00:00 1970 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=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,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 B971EC388F7 for ; Tue, 3 Nov 2020 20:59:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7AFAF223BF for ; Tue, 3 Nov 2020 20:59:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604437162; bh=AEjNpfgNS/by2nCOTPsKsz2AxJQ8Kb9EBXRz7/Ycyxk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=SYJGZjCyAHk4B57RS6uiZzn7TPne1GAUBs7bGIBE+p14NcTJoqPkmv4xG4uvk6gbu mAXS+UKekSgl1zLOM5wHs6KHkmNSyQFx/2crJLN35R16q98VndcZCKiSKoIi6uXvHG xizwebnzhgEPmpwY4D+k46YUygujV0JVGp8omZHE= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733104AbgKCU7V (ORCPT ); Tue, 3 Nov 2020 15:59:21 -0500 Received: from mail.kernel.org ([198.145.29.99]:34212 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733088AbgKCU7O (ORCPT ); Tue, 3 Nov 2020 15:59:14 -0500 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (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 82D6222226; Tue, 3 Nov 2020 20:59:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604437154; bh=AEjNpfgNS/by2nCOTPsKsz2AxJQ8Kb9EBXRz7/Ycyxk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VDb7oI+OwA36yBjCM+W18qcvMOTp9Wh+/dt97z44/Tl1aYJLN9x8fPWGb3qWcz013 SzvtuBlIWkK3rZERlJf3pm98wgynzm2DTYBX8iI4fyY8r3OORVrKJ6CRlqBdK3HDu6 P8I7ydpzKLdGtlUCyJampQ2LqvfArhUzLlewdUlk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Zhihao Cheng , Sascha Hauer , Richard Weinberger Subject: [PATCH 5.4 170/214] ubifs: Fix a memleak after dumping authentication mount options Date: Tue, 3 Nov 2020 21:36:58 +0100 Message-Id: <20201103203306.692028642@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201103203249.448706377@linuxfoundation.org> References: <20201103203249.448706377@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Zhihao Cheng commit 47f6d9ce45b03a40c34b668a9884754c58122b39 upstream. Fix a memory leak after dumping authentication mount options in error handling branch. Signed-off-by: Zhihao Cheng Cc: # 4.20+ Fixes: d8a22773a12c6d7 ("ubifs: Enable authentication support") Reviewed-by: Sascha Hauer Signed-off-by: Richard Weinberger Signed-off-by: Greg Kroah-Hartman --- fs/ubifs/super.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) --- a/fs/ubifs/super.c +++ b/fs/ubifs/super.c @@ -1123,6 +1123,18 @@ static int ubifs_parse_options(struct ub return 0; } +/* + * ubifs_release_options - release mount parameters which have been dumped. + * @c: UBIFS file-system description object + */ +static void ubifs_release_options(struct ubifs_info *c) +{ + kfree(c->auth_key_name); + c->auth_key_name = NULL; + kfree(c->auth_hash_name); + c->auth_hash_name = NULL; +} + /** * destroy_journal - destroy journal data structures. * @c: UBIFS file-system description object @@ -1632,8 +1644,7 @@ static void ubifs_umount(struct ubifs_in ubifs_lpt_free(c, 0); ubifs_exit_authentication(c); - kfree(c->auth_key_name); - kfree(c->auth_hash_name); + ubifs_release_options(c); kfree(c->cbuf); kfree(c->rcvrd_mst_node); kfree(c->mst_node); @@ -2201,6 +2212,7 @@ out_umount: out_unlock: mutex_unlock(&c->umount_mutex); out_close: + ubifs_release_options(c); ubi_close_volume(c->ubi); out: return err;