diff --git a/pkg/pool/pool.go b/pkg/pool/pool.go index f0bd580042f..cbd034e9e7c 100644 --- a/pkg/pool/pool.go +++ b/pkg/pool/pool.go @@ -112,12 +112,13 @@ func (p *BucketedBytes) Put(b *[]byte) { continue } *b = (*b)[:0] - p.mtx.Lock() - defer p.mtx.Unlock() p.buckets[i].Put(b) break } + p.mtx.Lock() + defer p.mtx.Unlock() + // We could assume here that our users will not make the slices larger // but lets be on the safe side to avoid an underflow of p.usedTotal. sz := uint64(cap(*b))