diff options
author | Tamir Duberstein <tamird@google.com> | 2020-03-06 12:30:37 -0800 |
---|---|---|
committer | gVisor bot <gvisor-bot@google.com> | 2020-03-06 12:31:43 -0800 |
commit | 6fa5cee82c0f515b001dee5f3840e1f875b2f477 (patch) | |
tree | adec65de9c23995348e898b3e52077edabf3b0c9 /pkg/tcpip/network/fragmentation | |
parent | 18d41cf15368c4d091ffdf84da655994eb1a1099 (diff) |
Prevent memory leaks in ilist
When list elements are removed from a list but not discarded, it becomes
important to invalidate the references they hold to their former
neighbors to prevent memory leaks.
PiperOrigin-RevId: 299412421
Diffstat (limited to 'pkg/tcpip/network/fragmentation')
-rw-r--r-- | pkg/tcpip/network/fragmentation/fragmentation.go | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/pkg/tcpip/network/fragmentation/fragmentation.go b/pkg/tcpip/network/fragmentation/fragmentation.go index 92f2aa13a..f42abc4bb 100644 --- a/pkg/tcpip/network/fragmentation/fragmentation.go +++ b/pkg/tcpip/network/fragmentation/fragmentation.go @@ -115,10 +115,12 @@ func (f *Fragmentation) Process(id uint32, first, last uint16, more bool, vv buf // Evict reassemblers if we are consuming more memory than highLimit until // we reach lowLimit. if f.size > f.highLimit { - tail := f.rList.Back() - for f.size > f.lowLimit && tail != nil { + for f.size > f.lowLimit { + tail := f.rList.Back() + if tail == nil { + break + } f.release(tail) - tail = tail.Prev() } } f.mu.Unlock() |