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 4AC92C433F5 for ; Wed, 24 Nov 2021 12:17:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243354AbhKXMVD (ORCPT ); Wed, 24 Nov 2021 07:21:03 -0500 Received: from mail.kernel.org ([198.145.29.99]:42356 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242481AbhKXMPA (ORCPT ); Wed, 24 Nov 2021 07:15:00 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id DBBCB61078; Wed, 24 Nov 2021 12:09:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1637755794; bh=XTHDUaTKtMLlO7Eusgtf9VOm6kCphF8Etxd85EpNUCk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=N2JvTvdyaOoma+y3kryliqjB5bRIv08/shJi+wtxOxceSIAY7EmPBYWW/nYYlGhzu fcHNU4r+KOYJoWyJwByJW2LMCJ9Zn7hJoSAJgf3D/HCBTTcHMDEX/uxjSAj/4b0PVt nSODQ981ibD5wn2j1/5k3ZR/OhEoLsXR2980onec= 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.9 027/207] btrfs: fix lost error handling when replaying directory deletes Date: Wed, 24 Nov 2021 12:54:58 +0100 Message-Id: <20211124115704.834025774@linuxfoundation.org> X-Mailer: git-send-email 2.34.0 In-Reply-To: <20211124115703.941380739@linuxfoundation.org> References: <20211124115703.941380739@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 @@ -2225,7 +2225,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; }