From d11ef20a936536aec811aec4e156366c5aeaac47 Mon Sep 17 00:00:00 2001 From: Michael Pratt Date: Fri, 29 Mar 2019 13:16:49 -0700 Subject: 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 --- pkg/sentry/mm/syscalls.go | 1 + 1 file changed, 1 insertion(+) (limited to 'pkg/sentry/mm') 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 } -- cgit v1.2.3