staging: mt7621-mmc: Fix: copy_from_user() returns a positive value

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>
This commit is contained in:
Christian Lütke-Stetzkamp 2018-04-07 10:16:24 +02:00 committed by Greg Kroah-Hartman
parent 2436c3156e
commit 0e0836625b

View file

@ -265,9 +265,8 @@ static ssize_t msdc_debug_proc_write(struct file *file,
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);