]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
xfs: remove redundant validation in xlog_recover_attri_commit_pass2
authorLong Li <leo.lilong@huawei.com>
Fri, 20 Mar 2026 02:11:30 +0000 (10:11 +0800)
committerCarlos Maiolino <cem@kernel.org>
Mon, 23 Mar 2026 10:00:08 +0000 (11:00 +0100)
Remove the redundant post-parse validation switch. By the time that
block is reached, xfs_attri_validate() has already guaranteed all name
lengths are non-zero via xfs_attri_validate_namelen(), and
xfs_attri_validate_name_iovec() has already returned -EFSCORRUPTED for
NULL names. For the REMOVE case, attr_value and value_len are
structurally guaranteed to be NULL/zero because the parsing loop only
populates them when value_len != 0. All checks in that switch are
therefore dead code.

Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Long Li <leo.lilong@huawei.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Carlos Maiolino <cem@kernel.org>
fs/xfs/xfs_attr_item.c

index 83d09635b2008e6514290d8b8243ffa32707ec40..82324f42537b5810782afd42b6410ea74a4726ed 100644 (file)
@@ -1132,52 +1132,6 @@ xlog_recover_attri_commit_pass2(
                return -EFSCORRUPTED;
        }
 
-       switch (op) {
-       case XFS_ATTRI_OP_FLAGS_REMOVE:
-               /* Regular remove operations operate only on names. */
-               if (attr_value != NULL || value_len != 0) {
-                       XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp,
-                                            attri_formatp, len);
-                       return -EFSCORRUPTED;
-               }
-               fallthrough;
-       case XFS_ATTRI_OP_FLAGS_PPTR_REMOVE:
-       case XFS_ATTRI_OP_FLAGS_PPTR_SET:
-       case XFS_ATTRI_OP_FLAGS_SET:
-       case XFS_ATTRI_OP_FLAGS_REPLACE:
-               /*
-                * Regular xattr set/remove/replace operations require a name
-                * and do not take a newname.  Values are optional for set and
-                * replace.
-                *
-                * Name-value set/remove operations must have a name, do not
-                * take a newname, and can take a value.
-                */
-               if (attr_name == NULL || name_len == 0) {
-                       XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp,
-                                            attri_formatp, len);
-                       return -EFSCORRUPTED;
-               }
-               break;
-       case XFS_ATTRI_OP_FLAGS_PPTR_REPLACE:
-               /*
-                * Name-value replace operations require the caller to
-                * specify the old and new names and values explicitly.
-                * Values are optional.
-                */
-               if (attr_name == NULL || name_len == 0) {
-                       XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp,
-                                            attri_formatp, len);
-                       return -EFSCORRUPTED;
-               }
-               if (attr_new_name == NULL || new_name_len == 0) {
-                       XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp,
-                                            attri_formatp, len);
-                       return -EFSCORRUPTED;
-               }
-               break;
-       }
-
        /*
         * Memory alloc failure will cause replay to abort.  We attach the
         * name/value buffer to the recovered incore log item and drop our