summaryrefslogtreecommitdiffhomepage
path: root/pkg/sentry/fsimpl/testutil/kernel.go
diff options
context:
space:
mode:
authorDean Deng <deandeng@google.com>2020-10-19 13:18:32 -0700
committergVisor bot <gvisor-bot@google.com>2020-10-19 13:20:13 -0700
commit63f4cef4d160e37b0cbe30ba60b2be95092790ed (patch)
tree6b191375887eedfc55c581fe3b81635ebab1b136 /pkg/sentry/fsimpl/testutil/kernel.go
parentcd108432a50ec777ce92f9d207154173e3f0b665 (diff)
[vfs2] Fix fork reference leaks.
PiperOrigin-RevId: 337919424
Diffstat (limited to 'pkg/sentry/fsimpl/testutil/kernel.go')
-rw-r--r--pkg/sentry/fsimpl/testutil/kernel.go7
1 files changed, 6 insertions, 1 deletions
diff --git a/pkg/sentry/fsimpl/testutil/kernel.go b/pkg/sentry/fsimpl/testutil/kernel.go
index 1813269e0..738c0c9cc 100644
--- a/pkg/sentry/fsimpl/testutil/kernel.go
+++ b/pkg/sentry/fsimpl/testutil/kernel.go
@@ -147,7 +147,12 @@ func CreateTask(ctx context.Context, name string, tc *kernel.ThreadGroup, mntns
FSContext: kernel.NewFSContextVFS2(root, cwd, 0022),
FDTable: k.NewFDTable(),
}
- return k.TaskSet().NewTask(config)
+ t, err := k.TaskSet().NewTask(ctx, config)
+ if err != nil {
+ config.ThreadGroup.Release(ctx)
+ return nil, err
+ }
+ return t, nil
}
func newFakeExecutable(ctx context.Context, vfsObj *vfs.VirtualFilesystem, creds *auth.Credentials, root vfs.VirtualDentry) (*vfs.FileDescription, error) {