Skip to content

Commit

Permalink
Merge pull request tock#4053 from tock/ipc-no-double-entry
Browse files Browse the repository at this point in the history
IPC: Avoid double grant entry
  • Loading branch information
brghena authored Jun 30, 2024
2 parents ab884ba + 5e36496 commit ab35489
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions kernel/src/ipc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,13 @@ impl<const NUM_PROCS: u8> IPC<NUM_PROCS> {
) -> Result<(), process::Error> {
let schedule_on_id = schedule_on.index().ok_or(process::Error::NoSuchApp)?;
let called_from_id = called_from.index().ok_or(process::Error::NoSuchApp)?;

// Verify that IPC is not trying to share with the same app. If so, this
// will cause a double grant enter if we don't return now.
if schedule_on_id == called_from_id {
return Err(process::Error::AlreadyInUse);
}

self.data.enter(schedule_on, |_, schedule_on_data| {
self.data.enter(called_from, |_, called_from_data| {
// If the other app shared a buffer with us, make
Expand Down

0 comments on commit ab35489

Please sign in to comment.