Re: [PATCH v2] ntfs: fix missing kstrdup() error check in ntfs_write_volume_label()

From: Namjae Jeon

Date: Fri May 08 2026 - 23:15:34 EST


On Fri, May 8, 2026 at 4:29 PM Zhan Xusheng <zhanxusheng1024@xxxxxxxxx> wrote:
>
> 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@xxxxxxxxx>
> Signed-off-by: Zhan Xusheng <zhanxusheng@xxxxxxxxxx>
Applied it to #ntfs-next.
Thanks!