diff options
Diffstat (limited to 'pkg/sentry/fs')
-rw-r--r-- | pkg/sentry/fs/dirent_cache.go | 2 | ||||
-rwxr-xr-x | pkg/sentry/fs/dirent_list.go | 8 | ||||
-rwxr-xr-x | pkg/sentry/fs/event_list.go | 8 | ||||
-rw-r--r-- | pkg/sentry/fs/inotify.go | 5 |
4 files changed, 16 insertions, 7 deletions
diff --git a/pkg/sentry/fs/dirent_cache.go b/pkg/sentry/fs/dirent_cache.go index 25514ace4..33de32c69 100644 --- a/pkg/sentry/fs/dirent_cache.go +++ b/pkg/sentry/fs/dirent_cache.go @@ -101,8 +101,6 @@ func (c *DirentCache) remove(d *Dirent) { panic(fmt.Sprintf("trying to remove %v, which is not in the dirent cache", d)) } c.list.Remove(d) - d.SetPrev(nil) - d.SetNext(nil) d.DecRef() c.currentSize-- if c.limit != nil { diff --git a/pkg/sentry/fs/dirent_list.go b/pkg/sentry/fs/dirent_list.go index 49d25da6c..acdce100c 100755 --- a/pkg/sentry/fs/dirent_list.go +++ b/pkg/sentry/fs/dirent_list.go @@ -135,8 +135,9 @@ func (l *direntList) InsertBefore(a, e *Dirent) { // Remove removes e from l. func (l *direntList) Remove(e *Dirent) { - prev := direntElementMapper{}.linkerFor(e).Prev() - next := direntElementMapper{}.linkerFor(e).Next() + linker := direntElementMapper{}.linkerFor(e) + prev := linker.Prev() + next := linker.Next() if prev != nil { direntElementMapper{}.linkerFor(prev).SetNext(next) @@ -149,6 +150,9 @@ func (l *direntList) Remove(e *Dirent) { } else { l.tail = prev } + + linker.SetNext(nil) + linker.SetPrev(nil) } // Entry is a default implementation of Linker. Users can add anonymous fields diff --git a/pkg/sentry/fs/event_list.go b/pkg/sentry/fs/event_list.go index 786686592..0274f41a2 100755 --- a/pkg/sentry/fs/event_list.go +++ b/pkg/sentry/fs/event_list.go @@ -135,8 +135,9 @@ func (l *eventList) InsertBefore(a, e *Event) { // Remove removes e from l. func (l *eventList) Remove(e *Event) { - prev := eventElementMapper{}.linkerFor(e).Prev() - next := eventElementMapper{}.linkerFor(e).Next() + linker := eventElementMapper{}.linkerFor(e) + prev := linker.Prev() + next := linker.Next() if prev != nil { eventElementMapper{}.linkerFor(prev).SetNext(next) @@ -149,6 +150,9 @@ func (l *eventList) Remove(e *Event) { } else { l.tail = prev } + + linker.SetNext(nil) + linker.SetPrev(nil) } // Entry is a default implementation of Linker. Users can add anonymous fields diff --git a/pkg/sentry/fs/inotify.go b/pkg/sentry/fs/inotify.go index 928c90aa0..e3a715c1f 100644 --- a/pkg/sentry/fs/inotify.go +++ b/pkg/sentry/fs/inotify.go @@ -143,7 +143,10 @@ func (i *Inotify) Read(ctx context.Context, _ *File, dst usermem.IOSequence, _ i } var writeLen int64 - for event := i.events.Front(); event != nil; event = event.Next() { + for it := i.events.Front(); it != nil; { + event := it + it = it.Next() + // Does the buffer have enough remaining space to hold the event we're // about to write out? if dst.NumBytes() < int64(event.sizeOf()) { |