From 2331e879af9ec87fec8bb283ba851e9e1e15187c Mon Sep 17 00:00:00 2001 From: Ted Yu Date: Wed, 20 Nov 2019 11:48:34 -0800 Subject: [PATCH] vc: Persist file handle may leak in FS#FromDisk Fixes #2233 Signed-off-by: Ted Yu --- virtcontainers/persist/fs/fs.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/virtcontainers/persist/fs/fs.go b/virtcontainers/persist/fs/fs.go index 0b4f28bc02..8aca6fb9a1 100644 --- a/virtcontainers/persist/fs/fs.go +++ b/virtcontainers/persist/fs/fs.go @@ -201,11 +201,11 @@ func (fs *FS) FromDisk(sid string) (persistapi.SandboxState, map[string]persista return ss, nil, err } + defer cf.Close() var cstate persistapi.ContainerState if err := json.NewDecoder(cf).Decode(&cstate); err != nil { return ss, nil, err } - cf.Close() fs.containerState[cid] = cstate }