Skip to content

Commit cab36da

Browse files
Dan Carpentergregkh
authored andcommitted
Staging: comedi: Return -EFAULT if copy_to_user() fails
Return -EFAULT on error instead of the number of bytes remaining to be copied. Fixes: bac42fb ("comedi: get rid of compat_alloc_user_space() mess in COMEDI_CMD{,TEST} compat") Signed-off-by: Dan Carpenter <[email protected]> Cc: stable <[email protected]> Link: https://lore.kernel.org/r/X8c3pfwFy2jpy4BP@mwanda Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 12b38ea commit cab36da

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

drivers/staging/comedi/comedi_fops.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2987,7 +2987,9 @@ static int put_compat_cmd(struct comedi32_cmd_struct __user *cmd32,
29872987
v32.chanlist_len = cmd->chanlist_len;
29882988
v32.data = ptr_to_compat(cmd->data);
29892989
v32.data_len = cmd->data_len;
2990-
return copy_to_user(cmd32, &v32, sizeof(v32));
2990+
if (copy_to_user(cmd32, &v32, sizeof(v32)))
2991+
return -EFAULT;
2992+
return 0;
29912993
}
29922994

29932995
/* Handle 32-bit COMEDI_CMD ioctl. */

0 commit comments

Comments
 (0)