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.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,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 7D08CC2D0CE for ; Sun, 29 Dec 2019 17:42:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 583CA21744 for ; Sun, 29 Dec 2019 17:42:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1577641370; bh=h4kSGNrKihKEQ5lM3kT69RDOm6a7IptB5XThD8KlVsA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=sYn9O+cTQRn/jM7OuR4RSJ6FLZOByP/SyvoHF1FHXZZclgYXWS0LNTZCsDRMmziiT 9ZOZ6yTGem5A5ARdQn+sB6dZA00R66J1oYLVA5gyvA9ONSvp3sfkkB/PoKGvyeM0l7 +zR3eKVqxctcdqr0Odhy1vamyajPQJXBSDB1peis= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730358AbfL2Rmt (ORCPT ); Sun, 29 Dec 2019 12:42:49 -0500 Received: from mail.kernel.org ([198.145.29.99]:49270 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730351AbfL2Rmp (ORCPT ); Sun, 29 Dec 2019 12:42:45 -0500 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 EF349207FF; Sun, 29 Dec 2019 17:42:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1577641365; bh=h4kSGNrKihKEQ5lM3kT69RDOm6a7IptB5XThD8KlVsA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1QSYryW9n8KxqW7pmc/hbFc71DILTcf2r1xvdYn0ObS840wMgHo44tZATIbYPmIw4 hBIVaunhQKdTAL20HN4RomvWRPXzfafBdccsCtsVEQwkaXoFG3sLdK+RzW8I3j2Fzn 79Req+ZzYFE3LWJYhNZRWecfrTqYGTH2W2UFjcD4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Filipe Manana , Johannes Thumshirn , Josef Bacik , David Sterba Subject: [PATCH 5.4 036/434] btrfs: do not leak reloc root if we fail to read the fs root Date: Sun, 29 Dec 2019 18:21:29 +0100 Message-Id: <20191229172704.430999724@linuxfoundation.org> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20191229172702.393141737@linuxfoundation.org> References: <20191229172702.393141737@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Josef Bacik commit ca1aa2818a53875cfdd175fb5e9a2984e997cce9 upstream. If we fail to read the fs root corresponding with a reloc root we'll just break out and free the reloc roots. But we remove our current reloc_root from this list higher up, which means we'll leak this reloc_root. Fix this by adding ourselves back to the reloc_roots list so we are properly cleaned up. CC: stable@vger.kernel.org # 4.4+ Reviewed-by: Filipe Manana Reviewed-by: Johannes Thumshirn Signed-off-by: Josef Bacik Reviewed-by: David Sterba Signed-off-by: David Sterba Signed-off-by: Greg Kroah-Hartman --- fs/btrfs/relocation.c | 1 + 1 file changed, 1 insertion(+) --- a/fs/btrfs/relocation.c +++ b/fs/btrfs/relocation.c @@ -4555,6 +4555,7 @@ int btrfs_recover_relocation(struct btrf fs_root = read_fs_root(fs_info, reloc_root->root_key.offset); if (IS_ERR(fs_root)) { err = PTR_ERR(fs_root); + list_add_tail(&reloc_root->root_list, &reloc_roots); goto out_free; }