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 3C079C433EF for ; Wed, 24 Nov 2021 12:34:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244525AbhKXMh4 (ORCPT ); Wed, 24 Nov 2021 07:37:56 -0500 Received: from mail.kernel.org ([198.145.29.99]:48064 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244673AbhKXMc1 (ORCPT ); Wed, 24 Nov 2021 07:32:27 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 2F04F611C5; Wed, 24 Nov 2021 12:20:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1637756401; bh=ofFis8tbypFWQ+NVeEFdLnBQgIfNzMojlEJpiNDVXeU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UBOybkZ2MszUT1mtKuC8jGIRrdFhUCMA2dGHFdgY9zS3qpDmsQYQa9ngfqfsLU9Ym 46mkSl6kYgPyivDai7CKQd7VUo+Sh5gnSzqQbsZ2tK2pEokXGDJzNZo3Xv2K+f9a6R j315u5ybMvYjQdq+46WkluxLemA2aIhbSWz7yXxQ= 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.14 031/251] btrfs: fix lost error handling when replaying directory deletes Date: Wed, 24 Nov 2021 12:54:33 +0100 Message-Id: <20211124115711.321963280@linuxfoundation.org> X-Mailer: git-send-email 2.34.0 In-Reply-To: <20211124115710.214900256@linuxfoundation.org> References: <20211124115710.214900256@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 @@ -2286,7 +2286,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; }