summaryrefslogtreecommitdiffhomepage
path: root/pkg/sentry/fs/mounts.go
diff options
context:
space:
mode:
authorgVisor bot <gvisor-bot@google.com>2020-02-25 20:20:10 +0000
committergVisor bot <gvisor-bot@google.com>2020-02-25 20:20:10 +0000
commit306bfa7fa8ec42d86f82c319720f3474528b1e1c (patch)
treed8aaddab4f582d103129c8da9f6c1a45cef23eda /pkg/sentry/fs/mounts.go
parent95cfdd3054ca4a716ade773561fa9eae79073710 (diff)
parent53504e29ca27b8dc9e098fbb88983fdbce90cca3 (diff)
Merge release-20200219.0-34-g53504e2 (automated)
Diffstat (limited to 'pkg/sentry/fs/mounts.go')
-rw-r--r--pkg/sentry/fs/mounts.go10
1 files changed, 7 insertions, 3 deletions
diff --git a/pkg/sentry/fs/mounts.go b/pkg/sentry/fs/mounts.go
index 574a2cc91..c7981f66e 100644
--- a/pkg/sentry/fs/mounts.go
+++ b/pkg/sentry/fs/mounts.go
@@ -100,10 +100,14 @@ func newUndoMount(d *Dirent) *Mount {
}
}
-// Root returns the root dirent of this mount. Callers must call DecRef on the
-// returned dirent.
+// Root returns the root dirent of this mount.
+//
+// This may return nil if the mount has already been free. Callers must handle this
+// case appropriately. If non-nil, callers must call DecRef on the returned *Dirent.
func (m *Mount) Root() *Dirent {
- m.root.IncRef()
+ if !m.root.TryIncRef() {
+ return nil
+ }
return m.root
}