summaryrefslogtreecommitdiffhomepage
path: root/pkg/sentry
diff options
context:
space:
mode:
authorMichael Pratt <mpratt@google.com>2019-03-29 13:16:49 -0700
committerShentubot <shentubot@google.com>2019-03-29 13:17:56 -0700
commitd11ef20a936536aec811aec4e156366c5aeaac47 (patch)
tree2bd68da3261ab03416e1ed07079db15faf893e37 /pkg/sentry
parent69afd0438e3213b8bf6d74bdf9c288772f81e834 (diff)
Drop reference on shared anon mappable
We call NewSharedAnonMappable simply to use it for Mappable/MappingIdentity for shared anon mmap. From MMapOpts.MappingIdentity: "If MMapOpts is used to successfully create a memory mapping, a reference is taken on MappingIdentity." mm.createVMALocked (below) takes this additional reference, so we don't need the reference returned by NewSharedAnonMappable. Holding it leaks the mappable. PiperOrigin-RevId: 241038108 Change-Id: I78ee3af78e0cc7aac4063b274b30d0e41eb5677d
Diffstat (limited to 'pkg/sentry')
-rw-r--r--pkg/sentry/mm/syscalls.go1
1 files changed, 1 insertions, 0 deletions
diff --git a/pkg/sentry/mm/syscalls.go b/pkg/sentry/mm/syscalls.go
index 3725c98aa..f8f095fed 100644
--- a/pkg/sentry/mm/syscalls.go
+++ b/pkg/sentry/mm/syscalls.go
@@ -101,6 +101,7 @@ func (mm *MemoryManager) MMap(ctx context.Context, opts memmap.MMapOpts) (userme
if err != nil {
return 0, err
}
+ defer m.DecRef()
opts.MappingIdentity = m
opts.Mappable = m
}