]> git.ipfire.org Git - thirdparty/linux.git/commit
ntfs: fix missing kstrdup() error check in ntfs_write_volume_label()
authorZhan Xusheng <zhanxusheng@xiaomi.com>
Fri, 8 May 2026 07:29:34 +0000 (15:29 +0800)
committerNamjae Jeon <linkinjeon@kernel.org>
Sat, 9 May 2026 03:12:59 +0000 (12:12 +0900)
commitd1aabc2132d29224caa3c994dadd8224dc473ed9
tree7807e483800789430136da0baaf841d091b7894b
parent3086c49a075f144536db0268ad307e63a8e1dbdb
ntfs: fix missing kstrdup() error check in ntfs_write_volume_label()

ntfs_write_volume_label() does not check the return value of
kstrdup().  If the allocation fails, vol->volume_label is set to
NULL while the function returns success.  A subsequent
FS_IOC_GETFSLABEL then returns an empty string even though the
on-disk label was updated correctly.

Fix by allocating the new label before taking vol_ni->mrec_lock and
updating any on-disk metadata, so an -ENOMEM from kstrdup() leaves
both the in-memory and on-disk labels untouched and consistent.  On
success the preallocated copy replaces the old vol->volume_label.
Also move mark_inode_dirty_sync() into the success path so that it
is not called when no metadata was actually modified.

Fixes: 6251f0b0de7d ("ntfs: update super block operations")
Suggested-by: Hyunchul Lee <hyc.lee@gmail.com>
Signed-off-by: Zhan Xusheng <zhanxusheng@xiaomi.com>
Reviewed-by: Hyunchul Lee <hyc.lee@gmail.com>
Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
fs/ntfs/super.c