From 716019cf7d3627286a7eaabbe0ab28ca223d41bf Mon Sep 17 00:00:00 2001 From: Maciej Zimnoch Date: Thu, 26 Nov 2020 23:54:38 +0100 Subject: [PATCH] accounting: fix data race in Transferred() startedTransfers is accessed by multiple threads, and it wasn't protected by the mutex call in Transferred() func. Fixes #4799 --- fs/accounting/stats.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/fs/accounting/stats.go b/fs/accounting/stats.go index fbea0114f..83a4894fb 100644 --- a/fs/accounting/stats.go +++ b/fs/accounting/stats.go @@ -337,6 +337,8 @@ func (s *StatsInfo) String() string { // Transferred returns list of all completed transfers including checked and // failed ones. func (s *StatsInfo) Transferred() []TransferSnapshot { + s.mu.RLock() + defer s.mu.RUnlock() ts := make([]TransferSnapshot, 0, len(s.startedTransfers)) for _, tr := range s.startedTransfers {