mirror of
https://github.com/nilfs-dev/nilfs-utils.git
synced 2026-01-26 13:43:15 +00:00
mount.nilfs2: check return value of mnt_fs_set_root()
In nilfs_mnt_context_complete_root(), the return value of mnt_fs_set_root() is ignored. Since mnt_fs_set_root() involves memory allocation, it can fail and return a negative error code (e.g., -ENOMEM). Fix this by checking the return value and reporting an error if it fails. Signed-off-by: Ryusuke Konishi <konishi.ryusuke@gmail.com>
This commit is contained in:
parent
eba2555a37
commit
d0e8cc2caf
@ -457,9 +457,15 @@ static int nilfs_mnt_context_complete_root(struct libmnt_context *cxt)
|
||||
}
|
||||
|
||||
fs = nilfs_find_mount(cxt, mtab, mnt_context_get_target(cxt), NULL);
|
||||
if (fs)
|
||||
mnt_fs_set_root(mnt_context_get_fs(cxt), mnt_fs_get_root(fs));
|
||||
|
||||
if (fs) {
|
||||
res = mnt_fs_set_root(mnt_context_get_fs(cxt),
|
||||
mnt_fs_get_root(fs));
|
||||
if (res < 0) {
|
||||
error(_("%s: failed to copy root of the mount: %s"),
|
||||
progname, strerror(-res));
|
||||
goto failed;
|
||||
}
|
||||
}
|
||||
res = 0;
|
||||
failed:
|
||||
return res;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user