From bcd883f095d62ef790889e5516adc4f437512726 Mon Sep 17 00:00:00 2001 From: Dean Deng Date: Fri, 6 Nov 2020 12:59:44 -0800 Subject: 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 --- pkg/sentry/fsimpl/kernfs/filesystem.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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) } -- cgit v1.2.3