From: Stanislav Kinsbursky Date: Mon, 1 Apr 2013 07:40:51 +0000 (+0400) Subject: ipc: set msg back to -EAGAIN if copy wasn't performed X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=2dc958fa2fe6987e7ab106bd97029a09a82fcd8d;p=GitHub%2Fmoto-9609%2Fandroid_kernel_motorola_exynos9610.git ipc: set msg back to -EAGAIN if copy wasn't performed 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 Signed-off-by: Linus Torvalds --- diff --git a/ipc/msg.c b/ipc/msg.c index 31cd1bf6af27..fede1d06ef30 100644 --- a/ipc/msg.c +++ b/ipc/msg.c @@ -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++;