Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp3012921pxb; Mon, 18 Oct 2021 06:35:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwmm7plqlNDm3icKe8nkZbijNzBqsnWSq+CwHhZkyJAsXAAHQ530BIbEV+52of6GA4GuRz0 X-Received: by 2002:a63:7010:: with SMTP id l16mr23777167pgc.32.1634564159666; Mon, 18 Oct 2021 06:35:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634564159; cv=none; d=google.com; s=arc-20160816; b=MMYITr4HUNSOdyzdahmNNqurcuIaRZrwA/hnzC+j7e1dr2tyM4AtGiQ4fK59l8MRjy 3JoopR4BEDiSXrVL6juH1zmDvh8VEeRXekXeydAVZcJ4x8zz3UUGLi0qAwgwEFRASuua P8W++e+auSMHGoU+t6zZCjwAcKgkBbFqNEL0DN0WcWZnIX+YI5Q6i8mONevl13zJ4flF WUf3ys95QzQi7cbYK/2D3Fs0p5kAHUtx1l7lbh35cNzGkTU7O9i0h2vgGrbLUiEDw/mY p+TNJAbowXGNoVhxxCUe85lp7phSsADBv/TQrxb45khcO+alOszowdw8OBHgdskv5HiW YOCQ== 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=2mdcwCawt7GkN+MBX8L6Y1IV4AI9qftSTVdH2jriwZI=; b=wqx/rN2FphC3RPMh36ve9QK8wld4+AlndpgB2LFELzqKihUW+rq0POAepWLVLkSNDT AiIkUpOSJE+PtYqYq3l4+7P3O296oq2TyecRDdna7sTEqaNXWPgEDP9wggZtunsYfO4k zk3+JxNDx3iHOiqjkiSD2ywPssTr6Y2/6mQFzYir2z3pKDbnFi4TBpCBajnf4PeuQFei B575irMt6ZCWmXmkwMdnlSOwn6nYZFBAmSbhF4W9Tp73gXxP0XGYP8sEymHKw7t5/9y5 vLQXttk+WyEY3020XRWqAJqomCX/dutUgNyVVzAqRZHc7y7gcSAU2ORlgjsCzI41hS2i hDow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=MbSP4GGT; 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 v12si3062119plp.293.2021.10.18.06.35.46; Mon, 18 Oct 2021 06:35:59 -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=MbSP4GGT; 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 S232248AbhJRNg7 (ORCPT + 99 others); Mon, 18 Oct 2021 09:36:59 -0400 Received: from mail.kernel.org ([198.145.29.99]:44136 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232476AbhJRNfP (ORCPT ); Mon, 18 Oct 2021 09:35:15 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 2E196613A7; Mon, 18 Oct 2021 13:30:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1634563834; bh=aG/1wgu7KSu/igqfsacCS8EE8z6XlRAZY/kg7Zy45q8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MbSP4GGTGAJjUUQh8MB5s1AGGoraLNY1z0Xm3iV62JmhrTKkvSKmqSmY+0hhOlZF3 QIyzEJLllBJihJqM0iZaiuwlwITQXgnWb/WV48+TMvN2KYHcmzqz5jexMTs2D6bYER kOzoi8b+bGxkTlYjNi9XhGi2uI+ZXsgEcOx2bpvk= 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.4 15/69] btrfs: check for error when looking up inode during dir entry replay Date: Mon, 18 Oct 2021 15:24:13 +0200 Message-Id: <20211018132329.967988447@linuxfoundation.org> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211018132329.453964125@linuxfoundation.org> References: <20211018132329.453964125@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 @@ -1949,8 +1949,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; @@ -1970,12 +1970,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,