From 8bb50dab790d575a83a935cf3361099cdb1a6aac Mon Sep 17 00:00:00 2001 From: Zhaozhong Ni Date: Tue, 21 Aug 2018 16:51:08 -0700 Subject: 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 --- pkg/sentry/fs/gofer/inode_state.go | 9 ++++++--- 1 file 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 { -- cgit v1.2.3