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:
parent
f5850e8e30
commit
b5eeab6e06
1 changed files with 2 additions and 1 deletions
|
@ -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)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue