From 2105158d4bee4fb36658dba32eb8104cf4e96467 Mon Sep 17 00:00:00 2001 From: Andrei Vagin Date: Wed, 15 May 2019 17:20:14 -0700 Subject: [PATCH] gofer: don't call hostfile.Close if hostFile is nil PiperOrigin-RevId: 248437159 Change-Id: Ife71f6ca032fca59ec97a82961000ed0af257101 --- pkg/sentry/fs/gofer/path.go | 8 ++++++-- 1 file 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 }