staging: sep: return -EFAULT on copy_from_user failure
authorDevendra Naga <devendra.aaru@gmail.com>
Sat, 27 Oct 2012 17:23:47 +0000 (13:23 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 29 Oct 2012 21:59:39 +0000 (14:59 -0700)
copy_from_user() returns the number of bytes remaining to be copied,
and it fails if user pointer is invalid, so return -EFAULT
so that the user gets a FAULT.

Signed-off-by: Devendra Naga <devendra.aaru@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/sep/sep_main.c

index a414e52..2c8df0e 100644 (file)
@@ -3431,7 +3431,7 @@ static ssize_t sep_create_dcb_dmatables_context(struct sep_device *sep,
        if (copy_from_user(dcb_args,
                        user_dcb_args,
                        num_dcbs * sizeof(struct build_dcb_struct))) {
-               error = -EINVAL;
+               error = -EFAULT;
                goto end_function;
        }
 
@@ -3619,7 +3619,7 @@ static ssize_t sep_create_msgarea_context(struct sep_device *sep,
 
        /* Copy input data to write() to allocated message buffer */
        if (copy_from_user(*msg_region, msg_user, msg_len)) {
-               error = -EINVAL;
+               error = -EFAULT;
                goto end_function;
        }