From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BF0C0A93F for ; Tue, 10 Jan 2023 18:07:29 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 45988C433D2; Tue, 10 Jan 2023 18:07:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1673374049; bh=UmmP9nAoiVGcDPOobEbHkraUxstIymo9uKKeIwU19sU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=0YFhnoGLFEHyEPxcruhdykdxWCVdHQ3bDh0EHHu3+GjNTkhm7iOTDO7qy0DScejAt OZfTB5TyafGEsa3YBBTrwCiX9AaUBBdDtszQDlKJkNAvk0JYgAXwU58CLoa+uL9oEI ffQLG9vHSa0R0s5JTqfEwJHYA6wmCsLGWO4jl3u8= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Christophe JAILLET , David Sterba , Sasha Levin Subject: [PATCH 6.0 012/148] btrfs: fix an error handling path in btrfs_defrag_leaves() Date: Tue, 10 Jan 2023 19:01:56 +0100 Message-Id: <20230110180017.571096489@linuxfoundation.org> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230110180017.145591678@linuxfoundation.org> References: <20230110180017.145591678@linuxfoundation.org> User-Agent: quilt/0.67 Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [ Upstream commit db0a4a7b8e95f9312a59a67cbd5bc589f090e13d ] All error handling paths end to 'out', except this memory allocation failure. This is spurious. So branch to the error handling path also in this case. It will add a call to: memset(&root->defrag_progress, 0, sizeof(root->defrag_progress)); Fixes: 6702ed490ca0 ("Btrfs: Add run time btree defrag, and an ioctl to force btree defrag") Signed-off-by: Christophe JAILLET Reviewed-by: David Sterba Signed-off-by: David Sterba Signed-off-by: Sasha Levin --- fs/btrfs/tree-defrag.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/fs/btrfs/tree-defrag.c b/fs/btrfs/tree-defrag.c index b6cf39f4e7e4..072ab9a1374b 100644 --- a/fs/btrfs/tree-defrag.c +++ b/fs/btrfs/tree-defrag.c @@ -31,8 +31,10 @@ int btrfs_defrag_leaves(struct btrfs_trans_handle *trans, goto out; path = btrfs_alloc_path(); - if (!path) - return -ENOMEM; + if (!path) { + ret = -ENOMEM; + goto out; + } level = btrfs_header_level(root->node); -- 2.35.1