From b5eeab6e061d183be050143426dd7fd774c89a20 Mon Sep 17 00:00:00 2001 From: Mabin Date: Fri, 27 Feb 2015 10:08:33 +0800 Subject: [PATCH] Add the file close operation before function return to advoid resource leaking Signed-off-by: Mabin --- daemon/graphdriver/devmapper/mount.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/daemon/graphdriver/devmapper/mount.go b/daemon/graphdriver/devmapper/mount.go index f64e995744..dc9026e404 100644 --- a/daemon/graphdriver/devmapper/mount.go +++ b/daemon/graphdriver/devmapper/mount.go @@ -55,13 +55,14 @@ func ProbeFsType(device string) (string, error) { if err != nil { return "", err } + defer file.Close() buffer := make([]byte, maxLen) l, err := file.Read(buffer) if err != nil { return "", err } - file.Close() + if uint64(l) != maxLen { return "", fmt.Errorf("unable to detect filesystem type of %s, short read", device) }