From: Christian Lütke-Stetzkamp Date: Sat, 7 Apr 2018 08:16:24 +0000 (+0200) Subject: staging: mt7621-mmc: Fix: copy_from_user() returns a positive value X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=0e0836625b0a5efb1b86b2836b0d2349c66753de;p=openwrt%2Fstaging%2Fblogic.git 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 Suggested-by: Dan Carpenter Signed-off-by: Christian Lütke-Stetzkamp Reviewed-by: NeilBrown Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/staging/mt7621-mmc/dbg.c b/drivers/staging/mt7621-mmc/dbg.c index ec95f6d49997..9a1809d74ea3 100644 --- a/drivers/staging/mt7621-mmc/dbg.c +++ b/drivers/staging/mt7621-mmc/dbg.c @@ -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);