summaryrefslogtreecommitdiffhomepage
path: root/pkg/sentry/fsimpl/kernfs/filesystem.go
diff options
context:
space:
mode:
authorDean Deng <deandeng@google.com>2020-11-06 12:59:44 -0800
committergVisor bot <gvisor-bot@google.com>2020-11-06 13:02:35 -0800
commitbcd883f095d62ef790889e5516adc4f437512726 (patch)
tree774da6a2bbf55e00f7729e1c916e4e1962bf245e /pkg/sentry/fsimpl/kernfs/filesystem.go
parent53eeb06ef14915eee799e9d7d59603ed2a0fe1c1 (diff)
Avoid extra DecRef on kernfs root for "kept" dentries.
The root dentry was not created through Inode.Lookup, so we should not release a reference even if inode.Keep() is true. PiperOrigin-RevId: 341103220
Diffstat (limited to 'pkg/sentry/fsimpl/kernfs/filesystem.go')
-rw-r--r--pkg/sentry/fsimpl/kernfs/filesystem.go2
1 files changed, 1 insertions, 1 deletions
diff --git a/pkg/sentry/fsimpl/kernfs/filesystem.go b/pkg/sentry/fsimpl/kernfs/filesystem.go
index 50aeab908..d125435d9 100644
--- a/pkg/sentry/fsimpl/kernfs/filesystem.go
+++ b/pkg/sentry/fsimpl/kernfs/filesystem.go
@@ -264,7 +264,7 @@ func (fs *Filesystem) Release(ctx context.Context) {
//
// Precondition: Filesystem.mu is held.
func (d *Dentry) releaseKeptDentriesLocked(ctx context.Context) {
- if d.inode.Keep() {
+ if d.inode.Keep() && d != d.fs.root {
d.decRefLocked(ctx)
}