f2fs: quota: fix stale lock holder on remount failure

F2FS remount can fail while duplicating a journalled quota file name.

f2fs_remount()
- sbi->umount_lock_holder = current
- kstrdup(F2FS_OPTION(sbi).s_qf_names[i])
  : fails
- free previously duplicated names
- return -ENOMEM

The direct return leaves umount_lock_holder pointing at the failed
remount context.  A later checkpoint may then wrongly treat another
context as the s_umount lock holder.

Add a restore_holder cleanup path and use it before returning -ENOMEM.

Fixes: eb85c2410d ("f2fs: quota: fix to avoid warning in dquot_writeback_dquots()")
Signed-off-by: Jianan Huang <jnhuang95@gmail.com>
Reviewed-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
This commit is contained in:
Jianan Huang 2026-09-09 19:46:14 +08:00 committed by Jaegeuk Kim
parent 3f72f38444
commit 3f140a60c9

View File

@ -2877,7 +2877,8 @@ static int __f2fs_remount(struct fs_context *fc, struct super_block *sb)
if (!org_mount_opt.s_qf_names[i]) { if (!org_mount_opt.s_qf_names[i]) {
for (j = 0; j < i; j++) for (j = 0; j < i; j++)
kfree(org_mount_opt.s_qf_names[j]); kfree(org_mount_opt.s_qf_names[j]);
return -ENOMEM; err = -ENOMEM;
goto restore_holder;
} }
} else { } else {
org_mount_opt.s_qf_names[i] = NULL; org_mount_opt.s_qf_names[i] = NULL;
@ -3138,6 +3139,7 @@ static int __f2fs_remount(struct fs_context *fc, struct super_block *sb)
sbi->mount_opt = org_mount_opt; sbi->mount_opt = org_mount_opt;
sb->s_flags = old_sb_flags; sb->s_flags = old_sb_flags;
restore_holder:
sbi->umount_lock_holder = NULL; sbi->umount_lock_holder = NULL;
return err; return err;
} }