Skip to contentSkip to conversation

Staging: comedi: Return -EFAULT if copy_to_user() fails

PATCH New Dan Carpenter 1 participant 1 message Dec 2, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Staging: comedi: Return -EFAULT if copy_to_user() fails

Return -EFAULT on error instead of the number of bytes remaining to be copied.

Fixes bac42fb21259 ("comedi: get rid of compat_alloc_user_space() mess in COMEDI_CMD{,TEST} compat")

---
Hi Al, this goes through your tree.

 drivers/staging/comedi/comedi_fops.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/staging/comedi/comedi_fops.c +3 -1
index d99231c737fb..80d74cce2a01 100644
@@ -2987,7 +2987,9 @@ static int put_compat_cmd(struct comedi32_cmd_struct __user *cmd32,
 	v32.chanlist_len = cmd->chanlist_len;
 	v32.data = ptr_to_compat(cmd->data);
 	v32.data_len = cmd->data_len;
-	return copy_to_user(cmd32, &v32, sizeof(v32));
+	if (copy_to_user(cmd32, &v32, sizeof(v32)))
+		return -EFAULT;
+	return 0;
 }
 
 /* Handle 32-bit COMEDI_CMD ioctl. */
Signature · 1 line
2.29.2