From 58294927f468a428c7a1ba09cf986fdca14a2747 Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Fri, 19 Feb 2021 12:54:38 +0300 Subject: cxl/mem: Return -EFAULT if copy_to_user() fails The copy_to_user() function returns the number of bytes remaining to be copied, but we want to return -EFAULT if the copy doesn't complete. Fixes: b754ffbbc0ee ("cxl/mem: Add basic IOCTL interface") Signed-off-by: Dan Carpenter Link: https://lore.kernel.org/r/YC+K3kgzqm20zCWY@mwanda Signed-off-by: Dan Williams --- drivers/cxl/mem.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'drivers/cxl') diff --git a/drivers/cxl/mem.c b/drivers/cxl/mem.c index 6d7d3870b5da..df895bcca63a 100644 --- a/drivers/cxl/mem.c +++ b/drivers/cxl/mem.c @@ -752,7 +752,10 @@ static int cxl_send_cmd(struct cxl_memdev *cxlmd, if (rc) return rc; - return copy_to_user(s, &send, sizeof(send)); + if (copy_to_user(s, &send, sizeof(send))) + return -EFAULT; + + return 0; } static long __cxl_memdev_ioctl(struct cxl_memdev *cxlmd, unsigned int cmd, -- cgit v1.2.3