Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id EE42DC433F5 for ; Wed, 24 Nov 2021 12:03:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232320AbhKXMGe (ORCPT ); Wed, 24 Nov 2021 07:06:34 -0500 Received: from mail.kernel.org ([198.145.29.99]:60698 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242075AbhKXMFS (ORCPT ); Wed, 24 Nov 2021 07:05:18 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 9428560FDA; Wed, 24 Nov 2021 12:02:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1637755329; bh=OvZ9OPZnsXe6Z3eJ9/ts3KWOptopX93zvoA1W6R0HnU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Hwmv/0kcLCobr7Va1NYj2x1Ti4GYrkvbisnbjW5mGaUPQ54N1Z0gS6mq3fXIGr84P L6f/Gu6YB3Vs3ZpGOO81RW5J3jx/QHp3KRdeefa1NZT9y35UYbGeCG/jTXGQCe1du9 gRT1gEBfWoh5K1AZtMk3gZFLe3Io5TmT2cFeoesU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Josef Bacik , Filipe Manana , David Sterba Subject: [PATCH 4.4 023/162] btrfs: fix lost error handling when replaying directory deletes Date: Wed, 24 Nov 2021 12:55:26 +0100 Message-Id: <20211124115659.081105349@linuxfoundation.org> X-Mailer: git-send-email 2.34.0 In-Reply-To: <20211124115658.328640564@linuxfoundation.org> References: <20211124115658.328640564@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Filipe Manana commit 10adb1152d957a4d570ad630f93a88bb961616c1 upstream. At replay_dir_deletes(), if find_dir_range() returns an error we break out of the main while loop and then assign a value of 0 (success) to the 'ret' variable, resulting in completely ignoring that an error happened. Fix that by jumping to the 'out' label when find_dir_range() returns an error (negative value). CC: stable@vger.kernel.org # 4.4+ Reviewed-by: Josef Bacik Signed-off-by: Filipe Manana Signed-off-by: David Sterba Signed-off-by: Greg Kroah-Hartman --- fs/btrfs/tree-log.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) --- a/fs/btrfs/tree-log.c +++ b/fs/btrfs/tree-log.c @@ -2207,7 +2207,9 @@ again: else { ret = find_dir_range(log, path, dirid, key_type, &range_start, &range_end); - if (ret != 0) + if (ret < 0) + goto out; + else if (ret > 0) break; }