From: Darrick J. Wong <djwong@xxxxxxxxxx> Gate the NVREPLACE code on the op flags directly, instead of inferring it through args->new_namelen. Signed-off-by: Darrick J. Wong <djwong@xxxxxxxxxx> --- fs/xfs/libxfs/xfs_attr.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/fs/xfs/libxfs/xfs_attr.c b/fs/xfs/libxfs/xfs_attr.c index 996ef24482e1..1a047099e9c7 100644 --- a/fs/xfs/libxfs/xfs_attr.c +++ b/fs/xfs/libxfs/xfs_attr.c @@ -426,9 +426,15 @@ xfs_attr_complete_op( return XFS_DAS_DONE; args->attr_filter &= ~XFS_ATTR_INCOMPLETE; - if (args->new_namelen == 0) + if (xfs_attr_intent_op(attr) != XFS_ATTRI_OP_FLAGS_NVREPLACE) return replace_state; + /* + * NVREPLACE operations require the caller to set the old and new names + * explicitly. + */ + ASSERT(args->new_namelen > 0); + args->name = args->new_name; args->namelen = args->new_namelen; args->hashval = xfs_da_hashname(args->name, args->namelen);