[PATCH v4 3/6] ntfs: reinit search context before volume information lookup

From: DaeMyung Kang

Date: Sat May 30 2026 - 10:37:34 EST


On mount the volume inode is searched for $VOLUME_NAME and then, reusing
the same search context, for $VOLUME_INFORMATION. The $VOLUME_NAME lookup
is optional and its result is otherwise ignored.

Once lookup-time validation can reject a corrupt $VOLUME_NAME with -EIO,
the search context is left in an undefined state: ntfs_attr_find()
documents that on an actual error @ctx->attr is undefined. Continuing the
$VOLUME_INFORMATION search from that context is not contractually valid.

Reinitialize the search context before the $VOLUME_INFORMATION lookup so
it always starts from a well-defined state regardless of the
$VOLUME_NAME lookup outcome.

Signed-off-by: DaeMyung Kang <charsyam@xxxxxxxxx>
---
fs/ntfs/super.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/fs/ntfs/super.c b/fs/ntfs/super.c
index 140b8c8a811e..79b530280d87 100644
--- a/fs/ntfs/super.c
+++ b/fs/ntfs/super.c
@@ -1537,6 +1537,7 @@ static bool load_system_files(struct ntfs_volume *vol)
vol->volume_label = NULL;
}

+ ntfs_attr_reinit_search_ctx(ctx);
if (ntfs_attr_lookup(AT_VOLUME_INFORMATION, NULL, 0, 0, 0, NULL, 0,
ctx) || ctx->attr->non_resident || ctx->attr->flags) {
ntfs_attr_put_search_ctx(ctx);
--
2.43.0