mount.nilfs2: fix ignored error on remount target mismatch

In nilfs_prepare_mount(), when a rw->rw remount is attempted on a
different mount point, an error message is printed, but the function
fails to abort the process.

This occurs because the return variable 'res' remains 0 (success) when
jumping to the failure label.

While a regular mount would eventually fail in the system call, a fake
mount (-f) skips the system call and would incorrectly succeed with exit
code 0 despite the error.

Fix this by setting 'res' to -EINVAL.

Signed-off-by: Ryusuke Konishi <konishi.ryusuke@gmail.com>
This commit is contained in:
Ryusuke Konishi 2026-01-14 01:57:07 +09:00
parent 53a23b7069
commit d189cfcf5c

View File

@ -358,6 +358,7 @@ static int nilfs_prepare_mount(struct nilfs_mount_info *mi)
mnt_table_get_cache(mtab))) {
error(_("%s: different mount point (%s). remount failed."),
progname, mnt_context_get_target(cxt));
res = -EINVAL;
goto failed;
}