1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

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

Signed-off-by: Mabin <bin.ma@huawei.com>
This commit is contained in:
Mabin 2015-02-27 10:08:33 +08:00
parent f5850e8e30
commit b5eeab6e06

View file

@ -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)
}