copy_from_user() returns a positive value in case of an error, to fix
this the check is turned around, also a better return value is chosen.
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Suggested-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de>
Reviewed-by: NeilBrown <neil@brown.name>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
if (count > 255)
count = 255;
- ret = copy_from_user(cmd_buf, buf, count);
- if (ret < 0)
- return -1;
+ if (copy_from_user(cmd_buf, buf, count))
+ return -EFAULT;
cmd_buf[count] = '\0';
printk("msdc Write %s\n", cmd_buf);