提交 7836a2d9 编写于 作者: A Alexandre Bounine 提交者: Linus Torvalds

rapidio/rio_cm: use memdup_user() instead of duplicating code

Fix coccinelle warning about duplicating existing memdup_user function.

Link: http://lkml.kernel.org/r/20160811151737.20140-1-alexandre.bounine@idt.com
Link: https://lkml.org/lkml/2016/8/11/29Signed-off-by: NAlexandre Bounine <alexandre.bounine@idt.com>
Reported-by: Nkbuild test robot <fengguang.wu@intel.com>
Cc: Matt Porter <mporter@kernel.crashing.org>
Cc: Andre van Herk <andre.van.herk@prodrive-technologies.com>
Cc: Barry Wood <barry.wood@idt.com>
Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
上级 0a5bf409
......@@ -1841,24 +1841,19 @@ static int cm_chan_msg_send(void __user *arg)
{
struct rio_cm_msg msg;
void *buf;
int ret = 0;
int ret;
if (copy_from_user(&msg, arg, sizeof(msg)))
return -EFAULT;
if (msg.size > RIO_MAX_MSG_SIZE)
return -EINVAL;
buf = kmalloc(msg.size, GFP_KERNEL);
if (!buf)
return -ENOMEM;
if (copy_from_user(buf, (void __user *)(uintptr_t)msg.msg, msg.size)) {
ret = -EFAULT;
goto out;
}
buf = memdup_user((void __user *)(uintptr_t)msg.msg, msg.size);
if (IS_ERR(buf))
return PTR_ERR(buf);
ret = riocm_ch_send(msg.ch_num, buf, msg.size);
out:
kfree(buf);
return ret;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册