From bf48ed32dd8be6bec2931c9f1eee4fd749affa21 Mon Sep 17 00:00:00 2001 From: Felix Lange Date: Mon, 3 Aug 2015 02:42:45 +0200 Subject: [PATCH] metrics: fix file descriptor leak when reading disk stats on linux The disk stats file was not closed after reading. --- metrics/disk_linux.go | 1 + 1 file changed, 1 insertion(+) diff --git a/metrics/disk_linux.go b/metrics/disk_linux.go index e0c8a1a3a7..8967d490e8 100644 --- a/metrics/disk_linux.go +++ b/metrics/disk_linux.go @@ -34,6 +34,7 @@ func ReadDiskStats(stats *DiskStats) error { if err != nil { return err } + defer inf.Close() in := bufio.NewReader(inf) // Iterate over the IO counter, and extract what we need