[vfs2] Don't take reference in Task.MountNamespaceVFS2 and MountNamespace.Root.

This fixes reference leaks related to accidentally forgetting to DecRef()
after calling one or the other.

PiperOrigin-RevId: 336918922
This commit is contained in:
Dean Deng
2020-10-13 11:31:22 -07:00
committed by gVisor bot
parent d9b32efb30
commit 432963dd2d
21 changed files with 54 additions and 34 deletions
+4 -1
View File
@@ -95,10 +95,13 @@ func NewAccessor(ctx context.Context, vfsObj *vfs.VirtualFilesystem, creds *auth
if err != nil {
return nil, err
}
// Pass a reference on root to the Accessor.
root := mntns.Root()
root.IncRef()
return &Accessor{
vfsObj: vfsObj,
mntns: mntns,
root: mntns.Root(),
root: root,
creds: creds,
}, nil
}
@@ -53,6 +53,7 @@ func setupDevtmpfs(t *testing.T) (context.Context, *auth.Credentials, *vfs.Virtu
t.Fatalf("failed to create tmpfs root mount: %v", err)
}
root := mntns.Root()
root.IncRef()
devpop := vfs.PathOperation{
Root: root,
Start: root,