From patchwork Thu Jan 2 22:05:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 234581 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=unavailable 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 3C9B2C3F68F for ; Thu, 2 Jan 2020 22:49:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 03C8C24653 for ; Thu, 2 Jan 2020 22:49:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1578005349; bh=jSk5/jasQckc5yZW/yS4DCLccMrVYTQ69dLLK9V/XM8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=wfk+PeCKqgZkuWcCOZmz9WPjmNoJUuJFw/prIb+cN1zLtrrFAAtqa11e3X2pj+XAe ryMlEPAw3q32kVK0+14y80lFVD9JggGBwA3n6GUKNadCgsSlYU15Th8HDycuUTJYT6 tfTBe1gz1/YsxgxyPrENyHO2kWTqlKHS3/G8OJLg= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729478AbgABW1R (ORCPT ); Thu, 2 Jan 2020 17:27:17 -0500 Received: from mail.kernel.org ([198.145.29.99]:55476 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729708AbgABW1Q (ORCPT ); Thu, 2 Jan 2020 17:27:16 -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 C31A920863; Thu, 2 Jan 2020 22:27:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1578004036; bh=jSk5/jasQckc5yZW/yS4DCLccMrVYTQ69dLLK9V/XM8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gxvzjxzJUJTzB54zJslwwDLjbqA49rQgJVUxVixHf+HXXV6QJS4Wi40cOLmutiOfk 9j7x3L5EoykDGPPw+i7VUVWkvESORM0Sne98KM/4M5biC14e3Lp/6bsAxOJ8WoyBEr nRdkbkfYls5Dc62tLv8PFIrzaAdDM0RRUqGMwYX4= 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 4.9 002/171] btrfs: do not leak reloc root if we fail to read the fs root Date: Thu, 2 Jan 2020 23:05:33 +0100 Message-Id: <20200102220547.250215374@linuxfoundation.org> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200102220546.960200039@linuxfoundation.org> References: <20200102220546.960200039@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: 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 @@ -4587,6 +4587,7 @@ int btrfs_recover_relocation(struct btrf 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; }