Add the file close operation before function return to advoid resource leaking

Signed-off-by: Mabin <bin.ma@huawei.com>
Upstream-commit: b5eeab6e061d183be050143426dd7fd774c89a20
Component: engine
This commit is contained in:
Mabin
2015-02-28 00:24:41 +08:00
parent 2d06b1cf02
commit 0fd505f748
@@ -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)
}