summaryrefslogtreecommitdiffhomepage
path: root/pkg
diff options
context:
space:
mode:
authorIan Gudger <igudger@google.com>2018-06-12 17:03:31 -0700
committerShentubot <shentubot@google.com>2018-06-12 17:04:20 -0700
commitba426f7782d35f971820a0193cfda58485b92cad (patch)
tree6efc3dcb1553056388d83d1dacba260bf192eb08 /pkg
parentc2b3f04d1c7b5d376a3fa305fc5e309e9ec81d99 (diff)
Fix reference leak for negative dirents
PiperOrigin-RevId: 200306715 Change-Id: I7c80059c77ebd3d9a5d7d48b05c8e7a597f10850
Diffstat (limited to 'pkg')
-rw-r--r--pkg/sentry/fs/dirent.go9
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