diff options
author | Andrei Vagin <avagin@google.com> | 2019-05-15 17:20:14 -0700 |
---|---|---|
committer | Shentubot <shentubot@google.com> | 2019-05-15 17:21:10 -0700 |
commit | 2105158d4bee4fb36658dba32eb8104cf4e96467 (patch) | |
tree | bc977bea0aff5a39bf487e44842a128792c4fdbd /pkg | |
parent | 3abee2ecb929d8f16a8febabb482dd6e8ed8e768 (diff) |
gofer: don't call hostfile.Close if hostFile is nil
PiperOrigin-RevId: 248437159
Change-Id: Ife71f6ca032fca59ec97a82961000ed0af257101
Diffstat (limited to 'pkg')
-rw-r--r-- | pkg/sentry/fs/gofer/path.go | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/pkg/sentry/fs/gofer/path.go b/pkg/sentry/fs/gofer/path.go index aa3d3aaa6..875de8b5f 100644 --- a/pkg/sentry/fs/gofer/path.go +++ b/pkg/sentry/fs/gofer/path.go @@ -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 } |