summaryrefslogtreecommitdiffhomepage
path: root/pkg/sentry
diff options
context:
space:
mode:
authorgVisor bot <gvisor-bot@google.com>2021-07-23 20:42:56 +0000
committergVisor bot <gvisor-bot@google.com>2021-07-23 20:42:56 +0000
commit1527f1dd3181ee829e60bff86bd5e0b6c5456a90 (patch)
treebf743da4d9d7ce1b3dce52613af5f4217e53cb37 /pkg/sentry
parent59fda1d7d870f57aac31937669f3ab9a57457917 (diff)
parent3d0a9300050ad9a72d452ec862827e35e3f38dcc (diff)
Merge release-20210712.0-59-g3d0a93000 (automated)
Diffstat (limited to 'pkg/sentry')
-rw-r--r--pkg/sentry/kernel/semaphore/semaphore.go10
1 files changed, 5 insertions, 5 deletions
diff --git a/pkg/sentry/kernel/semaphore/semaphore.go b/pkg/sentry/kernel/semaphore/semaphore.go
index b7879d284..8610d3fc1 100644
--- a/pkg/sentry/kernel/semaphore/semaphore.go
+++ b/pkg/sentry/kernel/semaphore/semaphore.go
@@ -214,15 +214,14 @@ func (r *Registry) Remove(id ipc.ID, creds *auth.Credentials) error {
r.mu.Lock()
defer r.mu.Unlock()
- r.reg.Remove(id, creds)
-
index, found := r.findIndexByID(id)
if !found {
- // Inconsistent state.
- panic(fmt.Sprintf("unable to find an index for ID: %d", id))
+ return linuxerr.EINVAL
}
delete(r.indexes, index)
+ r.reg.Remove(id, creds)
+
return nil
}
@@ -245,7 +244,8 @@ func (r *Registry) newSetLocked(ctx context.Context, key ipc.Key, creator fs.Fil
index, found := r.findFirstAvailableIndex()
if !found {
- panic("unable to find an available index")
+ // See linux, ipc/sem.c:newary().
+ return nil, linuxerr.ENOSPC
}
r.indexes[index] = set.obj.ID