Skip to content

Commit

Permalink
ipc: set msg back to -EAGAIN if copy wasn't performed
Browse files Browse the repository at this point in the history
Make sure that msg pointer is set back to error value in case of
MSG_COPY flag is set and desired message to copy wasn't found.  This
garantees that msg is either a error pointer or a copy address.

Otherwise the last message in queue will be freed without unlinking from
the queue (which leads to memory corruption) and the dummy allocated
copy won't be released.

Signed-off-by: Stanislav Kinsbursky <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Stanislav Kinsbursky authored and torvalds committed Apr 2, 2013
1 parent 118c9a4 commit 2dc958f
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions ipc/msg.c
Original file line number Diff line number Diff line change
Expand Up @@ -872,6 +872,7 @@ long do_msgrcv(int msqid, void __user *buf, size_t bufsz, long msgtyp,
goto out_unlock;
break;
}
msg = ERR_PTR(-EAGAIN);
} else
break;
msg_counter++;
Expand Down

0 comments on commit 2dc958f

Please sign in to comment.