Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp13471693ybl; Sun, 29 Dec 2019 12:42:41 -0800 (PST) X-Google-Smtp-Source: APXvYqxpFzrE89F1g9MUaOAew/UCNVTV9/kwcouYdssv1gvoJP5mFCcDMId66cfbYfThL8JY0p28 X-Received: by 2002:a9d:1e4:: with SMTP id e91mr66137027ote.324.1577652161733; Sun, 29 Dec 2019 12:42:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1577652161; cv=none; d=google.com; s=arc-20160816; b=XKiUF+zvC9V3b8kt3QGlPqe/UJkIu8EYv4P5eEz/hdzbvOAu+gb0+RpQEV+tgeEEVX BHnjSY7bmKan+PABF+MR5oK1ybMv//5EEHgyogccERMwod0HBxcIctl2QFjTxUnsNFjT PZyh05lninHiYWaXtufiGNVDeWjpWcLhm8G1rayxfV98ghG7dfJEmK6qpIsmGPXGiduD KH+yVtzJzugd2MHZxYnL2am/CTEPrawCojxSFBzjqIWK1K6Z65elek4yBaJOVfSvnJI6 Rs8kKwhsM8wjQCbLJWFFPmJoVRNQvjXVF5oP0dKZ4/sFwal0ANDlBDdl020eFdxfSJgk piGQ== 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=AswLrq+9DhFjn3snmG3oFo8rf1DPZSc98XERYHzI2Is=; b=RgOg0YvFRPYwQJih6FTXFbBqN3g7GH77eOd6lLddGdm50Y5j+UN++FpCu2aTIpclss CJLCNumSEnz3FD2uMi+IOdgVXPlWGJ8Kl/9i+vCrEA8m3hSgElLVoT/GbEo9KdqkcJQx oV9nOoPu1BCC5pfmzo0aJxbtidolMoU8AuYbgSUCXiXnCaGwBVIJ/+d7QA5Aj/l0hxRp e0pK361wl2iBSQEBtEJ0tD1tn3j2N532tqPWNmVfQprjnJTs4dsg1ZS6HMP7oCId1u3/ TPL9/3l2+b/E7GweVIAvmzU7OtTCmXkGkB01kso5zuNUP/3MiUUxcSpYRKFvpEKW1fMe 0Yfw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=1QSYryW9; 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 x16si22558625otp.184.2019.12.29.12.42.31; Sun, 29 Dec 2019 12:42:41 -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=1QSYryW9; 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 S1730364AbfL2Rmu (ORCPT + 99 others); Sun, 29 Dec 2019 12:42:50 -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: 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 @@ -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; }