Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp805558pxb; Tue, 3 Nov 2020 13:03:00 -0800 (PST) X-Google-Smtp-Source: ABdhPJx7Zh237JooR1h8NMEM4UJN21WnW1uWbGJB2WtI9UseqWxFVaNezrNMXBeMC+yHfJt7zWeP X-Received: by 2002:a50:d8ce:: with SMTP id y14mr21135041edj.90.1604437379919; Tue, 03 Nov 2020 13:02:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604437379; cv=none; d=google.com; s=arc-20160816; b=nVRJBCzadXSo3S1RRpwoqGanto14YRawYuvzda1nuuXYiPR0QIUqF+NXgtmWZwtgM0 d3dQ80WbnlzdB2Wz9UnnD0EI+W8YKSXqmX1gZvp6TcWAjUTuP3HMrWQucdnS8fzb088L 039tntdNLNCjbARdOI39sXYSYGWE9FRVt8d/uKxwbvClIt6FaZaGtfi+5TK2bOIkRlWu Mt4L+kYqnhhZL3yToRXzzJ+c4UlfuklyfDLj02KSojwMbDM58lWjSbOLLTXZxlfwZwjG nKkJPvxdQGIHjnH0Us4XqfGIua40Npda14SwqmgHmaqW+EqBrgt4C8F3lXMeQS7Lo5OL qSLQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=+E2s6oK5CavLyriuD85mtDnLOaNyTBusq+MzHtktVIo=; b=J6rDf+ys7QicNP5RTD5AsWLH/vc6VISVCtn/jlyjxVmROVp+CotAB2o7WBjgIykRD+ Ufw0aZNceyvWFnVl1FzILQ6AP4E812hO1idSvpI5a4ZUmSmD8Ot/v8bq9Ky0BnVBLust VtegcusOkMHIU/FEmwUnIL2f5Zy2j8sAi41lfUam67ukRTwiAQJiivYsBLCowavebDpE jDtqIPMyq7FMu4+oni9OzI04uWKOShVbUJl5+Vhpqo9hqM/SIGsloNlNBC06qQJD7r12 MpmgunjWco1FAQAM+CyhcCjySwGwBoLPbgxoUtK4hGccnzQmFzX3/NkJY+qM2KavPe0i Z8Eg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=VDb7oI+O; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k18si13599645edf.5.2020.11.03.13.02.36; Tue, 03 Nov 2020 13:02:59 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=VDb7oI+O; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730845AbgKCU7U (ORCPT + 99 others); Tue, 3 Nov 2020 15:59:20 -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;