Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp3027516pxb; Mon, 18 Oct 2021 06:54:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwE30buCs6oz5DO6u1gKJvWdm4No0SR1Opf0NbdCGlubtCPANeU53+TgbYzn+4Pz/KzHXa+ X-Received: by 2002:a63:3e84:: with SMTP id l126mr12310640pga.341.1634565256816; Mon, 18 Oct 2021 06:54:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634565256; cv=none; d=google.com; s=arc-20160816; b=iA9LwTAehlcEb3Z7/0/Dgq5iJV5vzWCOELDayMvo2i+cBEuovJ62P/lgTlTdEwcqR9 N5ztoo2Q1et5TOUIvBiBFY4/Xvy4C1sovQssmhbXoF3tKY1TU8S5xTGkN86mWuzvgulc 3PAJ9u8x/t1R8rXBizItzjRB3rJSma4XfJTwmieoYJZcXfrXs2Lh0sty/e1IW7HGKblL 1zwY8OIP8mfTWolvX9c7Oo5Gx/hE4bcnwFmECk9BrO2AHRRtH+IZck0q1yNvv3dKjFcH PMJtTMrI2E0JUu6ACeW3ZdaNAlKGgezgEtVpNKI+LlchnDIeZHPLEjFgmXBerupFiUuX 1Brw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=ZzIf9FHxhy4dDh/gUBu3yT3nQE9PLoHNTBfGu5OuQww=; b=nUs72NWsI2MFCr+OYZCPFPy6M07GL4TuXszG4wlC1HEuHfkZMWL/mFg5A7KTBKquqK +WMPaJQo6as8dFU9A+tdOqGCyMOx0MrFU05syohtPWqHB3EIma8kLpc9X5fuG7qnlLwt Sp+0nbu9ClPFpyTRsxMh5rlSiLQbLpO3ryt4ULjQ4G/dBBGzP0gfiALeX01vDRa9xxWu UpoXn0pYOMkgwMzz8m2KnB61GHf8lptWNABzEEHVCFfpqnDN9jBaybkGK63wwpX3iffm 1CayWs6fN5IBn6AsqpOzH5iNLU2xTp7VQxbBVAgpvz8nO6GXRV1eQGovrl3YpuBm+4Ch ja6w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ArqxQulO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k8si2476413pgl.527.2021.10.18.06.54.02; Mon, 18 Oct 2021 06:54:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ArqxQulO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232330AbhJRNzB (ORCPT + 99 others); Mon, 18 Oct 2021 09:55:01 -0400 Received: from mail.kernel.org ([198.145.29.99]:57384 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232847AbhJRNxA (ORCPT ); Mon, 18 Oct 2021 09:53:00 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 957BD61409; Mon, 18 Oct 2021 13:38:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1634564335; bh=NKMJmg+oIgJNSDtkTSgCog3BrBMeBjAqxcMvP8EuDW8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ArqxQulOm8maFBOz0RDVL8qyzB/J+j3sS2EiZBJir/404H2v/ncJyw6+vwp5JAmos Gw/Zc2BuXub5/d54tN0x+1u9vhLiLi2nSFySFkcjnJoq6aOlk4dsO8DTyqYRj1LydP SJZloSOpCimCX+3JeSVVOswaUE2I1hHLo/drMgDU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Filipe Manana , David Sterba Subject: [PATCH 5.14 033/151] btrfs: check for error when looking up inode during dir entry replay Date: Mon, 18 Oct 2021 15:23:32 +0200 Message-Id: <20211018132341.764155246@linuxfoundation.org> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211018132340.682786018@linuxfoundation.org> References: <20211018132340.682786018@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 cfd312695b71df04c3a2597859ff12c470d1e2e4 upstream. At replay_one_name(), we are treating any error from btrfs_lookup_inode() as if the inode does not exists. Fix this by checking for an error and returning it to the caller. CC: stable@vger.kernel.org # 4.14+ Signed-off-by: Filipe Manana Reviewed-by: David Sterba Signed-off-by: David Sterba Signed-off-by: Greg Kroah-Hartman --- fs/btrfs/tree-log.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) --- a/fs/btrfs/tree-log.c +++ b/fs/btrfs/tree-log.c @@ -1941,8 +1941,8 @@ static noinline int replay_one_name(stru struct btrfs_key log_key; struct inode *dir; u8 log_type; - int exists; - int ret = 0; + bool exists; + int ret; bool update_size = (key->type == BTRFS_DIR_INDEX_KEY); bool name_added = false; @@ -1962,12 +1962,12 @@ static noinline int replay_one_name(stru name_len); btrfs_dir_item_key_to_cpu(eb, di, &log_key); - exists = btrfs_lookup_inode(trans, root, path, &log_key, 0); - if (exists == 0) - exists = 1; - else - exists = 0; + ret = btrfs_lookup_inode(trans, root, path, &log_key, 0); btrfs_release_path(path); + if (ret < 0) + goto out; + exists = (ret == 0); + ret = 0; if (key->type == BTRFS_DIR_ITEM_KEY) { dst_di = btrfs_lookup_dir_item(trans, root, path, key->objectid,