diff options
author | Ian Gudger <igudger@google.com> | 2018-06-12 17:03:31 -0700 |
---|---|---|
committer | Shentubot <shentubot@google.com> | 2018-06-12 17:04:20 -0700 |
commit | ba426f7782d35f971820a0193cfda58485b92cad (patch) | |
tree | 6efc3dcb1553056388d83d1dacba260bf192eb08 /pkg | |
parent | c2b3f04d1c7b5d376a3fa305fc5e309e9ec81d99 (diff) |
Fix reference leak for negative dirents
PiperOrigin-RevId: 200306715
Change-Id: I7c80059c77ebd3d9a5d7d48b05c8e7a597f10850
Diffstat (limited to 'pkg')
-rw-r--r-- | pkg/sentry/fs/dirent.go | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/pkg/sentry/fs/dirent.go b/pkg/sentry/fs/dirent.go index a75c7ea7e..554aa30d8 100644 --- a/pkg/sentry/fs/dirent.go +++ b/pkg/sentry/fs/dirent.go @@ -1257,6 +1257,15 @@ func (d *Dirent) destroy() { // Drop all weak references. for _, w := range d.children { + if c := w.Get(); c != nil { + if c.(*Dirent).IsNegative() { + // The parent holds both weak and strong refs in the case of + // negative dirents. + c.DecRef() + } + // Drop the reference we just acquired in WeakRef.Get. + c.DecRef() + } w.Drop() } d.children = nil |