gofer: don't call hostfile.Close if hostFile is nil

PiperOrigin-RevId: 248437159
Change-Id: Ife71f6ca032fca59ec97a82961000ed0af257101
This commit is contained in:
Andrei Vagin 2019-05-15 17:20:14 -07:00 committed by Shentubot
parent 3abee2ecb9
commit 2105158d4b
1 changed files with 6 additions and 2 deletions

View File

@ -121,13 +121,17 @@ func (i *inodeOperations) Create(ctx context.Context, dir *fs.Inode, name string
qids, unopened, mask, p9attr, err := i.fileState.file.walkGetAttr(ctx, []string{name})
if err != nil {
newFile.close(ctx)
hostFile.Close()
if hostFile != nil {
hostFile.Close()
}
return nil, err
}
if len(qids) != 1 {
log.Warningf("WalkGetAttr(%s) succeeded, but returned %d QIDs (%v), wanted 1", name, len(qids), qids)
newFile.close(ctx)
hostFile.Close()
if hostFile != nil {
hostFile.Close()
}
unopened.close(ctx)
return nil, syserror.EIO
}