Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp3008404pxb; Mon, 18 Oct 2021 06:31:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxkSgYHHqQ4KsyUBMc4MhLvwIh6AfcQWBsh4q0Ra4rza0/KJR4DBeiy5+vluyCmS365V4fM X-Received: by 2002:a17:902:d488:b0:13f:165e:f491 with SMTP id c8-20020a170902d48800b0013f165ef491mr27481391plg.12.1634563864398; Mon, 18 Oct 2021 06:31:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634563864; cv=none; d=google.com; s=arc-20160816; b=d34+WP1FO+Y+uuMro5DDGFVE2KEbDJzxQzkrc2q2oBXvlM9wq7kA0YfLkYOyt3wvgg oFfZVtlG2lvNCzL9S8//BRrRJjoQKVuZzxL8kTpw7vYghZ5E1JS+T3FQ1O1PxMYREhcE HVv2KBfl9bI5d5vMemvCqeE3Zdjs1fya4GK3FkkM+WOEs3mzKbjw6N4sXYkaQ2dP6YyB BR16Z6vt3alJMlzZczp4XCfirlMnL4uvMqrJLFbT+YTRZW9qrv6a8/xuW09Ss3P/QdS6 be+B4oC0fhMzk5d68jqkJDW4GSw4M1/Y6841menWs/71FiQH9Js69JEbCJ5z8Wjxn3n2 XrVQ== 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=RQ9crasYXaw+Go3Ze5iB3xorkcWO8jyiO0SyuEcudV0=; b=Nt8Um2k+zYjIVaJdqJhjcrQx+s15cWf77DXpXpCTIt7u9KoPkeo+WHKSFn3xDbPgQK S805Xl0YxkAa1LWb2Az2PmiHEpS9Cokdfbd01dnnHYNchUo77Ryp84ZPXoRJii3OxNBw vkXhdxaq3jxdbZj16IL+rY3JWmILGWvcLoPNKHjS+w87xEhAr1MVH0T0kyVe1wEfaQ4q Frib0wJoeadnV1WW/uDeJmIPmf3esz0yqsUQ2cMZih9WEdYO3DsOXKiAyeKqZbCgbUYV htXxc6u7ouibwSTh0pH0oxwVe/d4EPnPRo1pVOB7r+eX8Jv6Sc+dhYuZ4IEwqT+AbAKc 3Rbg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=e7nvdkuG; 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 12si32555303pjl.32.2021.10.18.06.30.49; Mon, 18 Oct 2021 06:31:04 -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=e7nvdkuG; 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 S231795AbhJRNai (ORCPT + 99 others); Mon, 18 Oct 2021 09:30:38 -0400 Received: from mail.kernel.org ([198.145.29.99]:41286 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231959AbhJRN3M (ORCPT ); Mon, 18 Oct 2021 09:29:12 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 4F3F061077; Mon, 18 Oct 2021 13:27:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1634563621; bh=ew2EV4reE2dItotEpuyddWr8z0xQGblTQU+MtG6B9zo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=e7nvdkuGkX9VDBiKQODEvx/JyufOGIX6QhubGvRm4V9Ov2Wg+CjjcYOPhZJJA+/Dp HOja9Z+KaF9nY14co4eAgEvskBWr6owPk/oOCGSt5/X74gO8yOmBisWJhi7/TT898U HbScMjo5c+6HYGOCgXDtzZbv3mQmzfXa5uExtXoA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Filipe Manana , David Sterba Subject: [PATCH 4.14 06/39] btrfs: check for error when looking up inode during dir entry replay Date: Mon, 18 Oct 2021 15:24:15 +0200 Message-Id: <20211018132325.639431250@linuxfoundation.org> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211018132325.426739023@linuxfoundation.org> References: <20211018132325.426739023@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 @@ -1730,8 +1730,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; @@ -1751,12 +1751,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,