Received: by 2002:a17:90a:9103:0:0:0:0 with SMTP id k3csp11814470pjo; Thu, 2 Jan 2020 14:45:14 -0800 (PST) X-Google-Smtp-Source: APXvYqxyV/27zF4XSBzPEzbDRlglv90zS314IounvI1w3QR4UH+aDhzbBd4YbdA55m7QluGxtQJ/ X-Received: by 2002:a05:6830:1116:: with SMTP id w22mr96998447otq.63.1578005114043; Thu, 02 Jan 2020 14:45:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578005114; cv=none; d=google.com; s=arc-20160816; b=jlGG0z1ecxOEhZspx8KKRVMUzNyZDhwq2K89ydTMuEnInccJoLfIl5STKKntCnbCkN OYyfo/Fl7kCUFo1yo9FcMa+qwVCl4wmJgWlaxfZ4Ocjqd2trJZKO0obBKfGa98BJHaQ8 jWytOauNvu+VX6hThq8WQTw8b2TKoGtTeE6R7xV6Pm/CF+QdsazVjcL+WPbQ2nv0AbPW afyeFtehbeVyTF/29fuGkZwLP7mAnZ2jpBL7yTVxOuz2C9X4COJbAtMtYTpED/RWU9uc hHJPAiVkI41oOgxfEzwTjC+CXyQAQ0qKMhTQZUq2/sV24yiTCKjvxKQHb1M3QYdm2+Z/ dqkw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=xrkjJx7oO2spPHFlFL5aq2jMCRZUwyWYYTnwbxXEDHQ=; b=CxEDb/jq25j0oYrHA83yFzq+EX/Wxtpv0Y3DDXoHBqWC/mSPH3h+l1Xg7qR7ztMYQ0 5V4V+htu7s23G8SzlOmkdKqTdl4HGN4P/ELLyPjpmKP0Y7Q6H7szBGx0fEREVqrHb+9S 577YOQl9y5HPVPLy5lmFYiNNCEXsHSgUJEGakjnP7xbO6t6BVzUqlXkKAoSXJ8G1yGjk 3vjTAW1WSdQdUzkXdbShYYq2dRelb8AFWt3kHjIiaVmgfr3zw0YCrbwhP4zUpPsbBGTR S8yETZ0yVjp/RH7C1DT//16+bjFf9voyAhnJAOWg8FoFZ68hn7S0cW5DfB5i7AAEcSxX 5SdQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=HOYf2dkM; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i15si28031996otk.120.2020.01.02.14.45.02; Thu, 02 Jan 2020 14:45:14 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=HOYf2dkM; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730559AbgABWnz (ORCPT + 99 others); Thu, 2 Jan 2020 17:43:55 -0500 Received: from mail.kernel.org ([198.145.29.99]:42130 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730667AbgABWeD (ORCPT ); Thu, 2 Jan 2020 17:34:03 -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 8D5E721835; Thu, 2 Jan 2020 22:34:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1578004443; bh=nQT92VES4cV9D+HrZBfDmZA5vdKgHGuMiMjlgpw1iqY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HOYf2dkM9tK8dUzs52JWNtj0cU9H7HIFuhbKLEnTfXo14/wvhzmg/9mMXJqGfnSLm cek/rAtvlpuLg/co8hLOXrUC+tt74WCCcImRV8HemNXOMU8Xr3mtwbJQbRPfUIh8l9 YsW9tix81byUhTX/5j8sSWSsGHOD2VarH36GDGWE= 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.4 001/137] btrfs: do not leak reloc root if we fail to read the fs root Date: Thu, 2 Jan 2020 23:06:14 +0100 Message-Id: <20200102220546.831163853@linuxfoundation.org> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200102220546.618583146@linuxfoundation.org> References: <20200102220546.618583146@linuxfoundation.org> User-Agent: quilt/0.66 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 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 @@ -4454,6 +4454,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; }