Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion src/ipc/ipc-common.c
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,17 @@ void z_vrfy_ipc_msg_list_remove(struct ipc_msg *msg)
break;
}
}
K_OOPS(K_SYSCALL_VERIFY(found));

/*
* ipc_msg_list_remove() is normally called from ipc_msg_free() to drop
* a message that may or may not still be queued. A message that has
* already been sent (or was never queued) has a self-linked, empty list
* node, so removing it via list_item_del() is a harmless no-op that only
* touches &msg->list, which was already validated above. Only reject a
* non-empty node that is not on ipc->msg_list, i.e. one whose list
* pointers would make list_item_del() corrupt unrelated memory.
*/
K_OOPS(K_SYSCALL_VERIFY(found || list_is_empty(&msg->list)));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, now that I think about it, Copilot actually has a point here, but I would not fix it the way Copilot suggests, but I would simply add:

if (list_is_empty(&msg->list))
	return;

after the search loop, and have the original K_OOPS(K_SYSCALL_VERIFY(found)); after that.

z_impl_ipc_msg_list_remove(msg);
}
#include <zephyr/syscalls/ipc_msg_list_remove_mrsh.c>
Expand Down
Loading