diff options
author | Zhaozhong Ni <nzz@google.com> | 2018-08-21 16:51:08 -0700 |
---|---|---|
committer | Shentubot <shentubot@google.com> | 2018-08-21 16:52:27 -0700 |
commit | 8bb50dab790d575a83a935cf3361099cdb1a6aac (patch) | |
tree | 5fcdb2f6226f52cc55facf719aa659b716af5626 /pkg/sentry/fs/gofer/inode_state.go | |
parent | e29a02239eb27d4fe03e04f9fbdbc46e1655bf95 (diff) |
sentry: do not release gofer inode file state loading lock upon error.
When an inode file state failed to load asynchronuously, we want to report
the error instead of potentially panicing in another async loading goroutine
incorrectly unblocked.
PiperOrigin-RevId: 209683977
Change-Id: I591cde97710bbe3cdc53717ee58f1d28bbda9261
Diffstat (limited to 'pkg/sentry/fs/gofer/inode_state.go')
-rw-r--r-- | pkg/sentry/fs/gofer/inode_state.go | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/pkg/sentry/fs/gofer/inode_state.go b/pkg/sentry/fs/gofer/inode_state.go index 33ec33364..4f2b01c72 100644 --- a/pkg/sentry/fs/gofer/inode_state.go +++ b/pkg/sentry/fs/gofer/inode_state.go @@ -108,9 +108,13 @@ func (i *inodeFileState) loadLoading(_ struct{}) { // afterLoad is invoked by stateify. func (i *inodeFileState) afterLoad() { - load := func() error { + load := func() (err error) { // See comment on i.loading(). - defer i.loading.Unlock() + defer func() { + if err == nil { + i.loading.Unlock() + } + }() // Manually restore the p9.File. name, ok := i.s.inodeMappings[i.sattr.InodeID] @@ -121,7 +125,6 @@ func (i *inodeFileState) afterLoad() { } // TODO: Context is not plumbed to save/restore. ctx := &dummyClockContext{context.Background()} - var err error _, i.file, err = i.s.attach.walk(ctx, splitAbsolutePath(name)) if err != nil { |