[PATCH] ntfs: remove empty EA attribute pair

Namjae Jeon <[email protected]> Thu, 16 Jul 2026 11:46:36 +0900
Newsgroups dev.linux.lists.ntfs,org.kernel.vger.linux-fsdevel
Message-ID <[email protected]>
Removing the final xattr leaves an empty $EA stream. An empty $EA
attribute paired with $EA_INFORMATION is not a valid EA chain and
ntfsck reports it as corrupt.

Remove both attributes when the final EA entry is deleted.

Fixes: fc053f05ca28 ("ntfs: add reparse and ea operations")
Signed-off-by: Namjae Jeon <[email protected]>
---
 fs/ntfs/ea.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/fs/ntfs/ea.c b/fs/ntfs/ea.c
index 0eba3f41c7bb..88bfd6560692 100644
--- a/fs/ntfs/ea.c
+++ b/fs/ntfs/ea.c
@@ -275,6 +275,15 @@ static int ntfs_set_ea(struct inode *inode, const char *name, size_t name_len,
 		ea_info_qsize -= ea_size;
 		p_ea_info->ea_query_length = cpu_to_le32(ea_info_qsize);
 
+		if ((flags & XATTR_REPLACE) && !val_size && !ea_info_qsize) {
+			err = ntfs_attr_remove(ni, AT_EA, AT_UNNAMED, 0);
+			if (err)
+				goto out;
+
+			err = ntfs_attr_remove(ni, AT_EA_INFORMATION, AT_UNNAMED, 0);
+			goto out;
+		}
+
 		err = ntfs_write_ea(ni, AT_EA_INFORMATION, (char *)p_ea_info, 0,
 				sizeof(struct ea_information), false);
 		if (err)
-- 
2.25.1