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=-6.0 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY, 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 4F780C282C4 for ; Mon, 4 Feb 2019 10:55:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 21CBA20823 for ; Mon, 4 Feb 2019 10:55:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1549277759; bh=RNb5NCxpfuaO0Dt/MswiPURXM11Sfv3kOfpQqmzxe6E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=KNEpOyap5bIyX9HJpH3mct+Mp179JjszpZ0xPz+zVsI1P5CI0FqIwJSktzpjaTkSm w2ukFFWmumFWktGIbCUiHqx1apq1vaitQODDxJAHrVqmaKIVui94ZUtA8dGGU18ZrW 3hm1MuS9JXpZB4okTzoT2cyOHI2SbAsCnefrhGh4= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732590AbfBDKz5 (ORCPT ); Mon, 4 Feb 2019 05:55:57 -0500 Received: from mail.kernel.org ([198.145.29.99]:51010 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732769AbfBDKxX (ORCPT ); Mon, 4 Feb 2019 05:53:23 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.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 DCA45217D6; Mon, 4 Feb 2019 10:53:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1549277603; bh=RNb5NCxpfuaO0Dt/MswiPURXM11Sfv3kOfpQqmzxe6E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Anz7myjTr6qaEM9RSYlNLLvVNX6QDSMXuNUBrD2/pt2890B+TqY1eeNjeNA8GWDbd MvOdI9PE1UVMywYFRTxrHHlpqVRKY0EAHsuNMm9XGnTgKZdRTl9poCktc57W4BVb+c 0ZZV9N6bq5U/XPLDkFlk+CqTp7nv0oRAZDEq/Qms= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Nikolay Borisov , "Eric W. Biederman" , David Sterba Subject: [PATCH 4.20 67/80] btrfs: On error always free subvol_name in btrfs_mount Date: Mon, 4 Feb 2019 11:37:27 +0100 Message-Id: <20190204103629.409961513@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190204103620.287366543@linuxfoundation.org> References: <20190204103620.287366543@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.20-stable review patch. If anyone has any objections, please let me know. ------------------ From: Eric W. Biederman commit 532b618bdf237250d6d4566536d4b6ce3d0a31fe upstream. The subvol_name is allocated in btrfs_parse_subvol_options and is consumed and freed in mount_subvol. Add a free to the error paths that don't call mount_subvol so that it is guaranteed that subvol_name is freed when an error happens. Fixes: 312c89fbca06 ("btrfs: cleanup btrfs_mount() using btrfs_mount_root()") Cc: stable@vger.kernel.org # v4.19+ Reviewed-by: Nikolay Borisov Signed-off-by: "Eric W. Biederman" Reviewed-by: David Sterba Signed-off-by: David Sterba Signed-off-by: Greg Kroah-Hartman --- fs/btrfs/super.c | 3 +++ 1 file changed, 3 insertions(+) --- a/fs/btrfs/super.c +++ b/fs/btrfs/super.c @@ -1677,6 +1677,7 @@ static struct dentry *btrfs_mount(struct flags | SB_RDONLY, device_name, data); if (IS_ERR(mnt_root)) { root = ERR_CAST(mnt_root); + kfree(subvol_name); goto out; } @@ -1686,12 +1687,14 @@ static struct dentry *btrfs_mount(struct if (error < 0) { root = ERR_PTR(error); mntput(mnt_root); + kfree(subvol_name); goto out; } } } if (IS_ERR(mnt_root)) { root = ERR_CAST(mnt_root); + kfree(subvol_name); goto out; }