Skip to content

Commit

Permalink
ipc: simplify msg list search
Browse files Browse the repository at this point in the history
Signed-off-by: Peter Hurley <[email protected]>
Acked-by: Stanislav Kinsbursky <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
peterhurley authored and torvalds committed May 1, 2013
1 parent 8ac6ed5 commit d076ac9
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions ipc/msg.c
Original file line number Diff line number Diff line change
Expand Up @@ -836,19 +836,16 @@ long do_msgrcv(int msqid, void __user *buf, size_t bufsz, long msgtyp,

for (;;) {
struct msg_receiver msr_d;
struct list_head *tmp;
struct msg_msg *walk_msg;
long msg_counter = 0;

msg = ERR_PTR(-EACCES);
if (ipcperms(ns, &msq->q_perm, S_IRUGO))
goto out_unlock;

msg = ERR_PTR(-EAGAIN);
tmp = msq->q_messages.next;
while (tmp != &msq->q_messages) {
struct msg_msg *walk_msg;
list_for_each_entry(walk_msg, &msq->q_messages, m_list) {

walk_msg = list_entry(tmp, struct msg_msg, m_list);
if (testmsg(walk_msg, msgtyp, mode) &&
!security_msg_queue_msgrcv(msq, walk_msg, current,
msgtyp, mode)) {
Expand All @@ -865,7 +862,6 @@ long do_msgrcv(int msqid, void __user *buf, size_t bufsz, long msgtyp,
break;
msg_counter++;
}
tmp = tmp->next;
}
if (!IS_ERR(msg)) {
/*
Expand Down

0 comments on commit d076ac9

Please sign in to comment.