summaryrefslogtreecommitdiffhomepage
path: root/pkg/sentry/syscalls/linux
diff options
context:
space:
mode:
authorgVisor bot <gvisor-bot@google.com>2019-08-01 22:07:03 +0000
committergVisor bot <gvisor-bot@google.com>2019-08-01 22:07:03 +0000
commit0c27758b24801f1478cb63e466d0e5fbd02bcbed (patch)
tree4b5e8967a6c7822d4c26963b7d8cbef6326c46da /pkg/sentry/syscalls/linux
parentfad75173249339f0cf84e5bcdef57e029d40af87 (diff)
parentbad43772a1c3d0b2a755ab38caae12b6542fe7a2 (diff)
Merge bad43772 (automated)
Diffstat (limited to 'pkg/sentry/syscalls/linux')
-rw-r--r--pkg/sentry/syscalls/linux/sys_mount.go12
1 files changed, 10 insertions, 2 deletions
diff --git a/pkg/sentry/syscalls/linux/sys_mount.go b/pkg/sentry/syscalls/linux/sys_mount.go
index 9080a10c3..8c13e2d82 100644
--- a/pkg/sentry/syscalls/linux/sys_mount.go
+++ b/pkg/sentry/syscalls/linux/sys_mount.go
@@ -109,9 +109,17 @@ func Mount(t *kernel.Task, args arch.SyscallArguments) (uintptr, *kernel.Syscall
return 0, nil, syserror.EINVAL
}
- return 0, nil, fileOpOn(t, linux.AT_FDCWD, targetPath, true /* resolve */, func(root *fs.Dirent, d *fs.Dirent, _ uint) error {
+ if err := fileOpOn(t, linux.AT_FDCWD, targetPath, true /* resolve */, func(root *fs.Dirent, d *fs.Dirent, _ uint) error {
+ // Mount will take a reference on rootInode if successful.
return t.MountNamespace().Mount(t, d, rootInode)
- })
+ }); err != nil {
+ // Something went wrong. Drop our ref on rootInode before
+ // returning the error.
+ rootInode.DecRef()
+ return 0, nil, err
+ }
+
+ return 0, nil, nil
}
// Umount2 implements Linux syscall umount2(2).