[PATCH 09/10] staging: mt7621-mmc: Fix: copy_from_user() returns a positive value

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
Suggested-by: Dan Carpenter <dan.carpenter@xxxxxxxxxx>
Signed-off-by: Christian Lütke-Stetzkamp <christian@xxxxxxxx>
---
 drivers/staging/mt7621-mmc/dbg.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/mt7621-mmc/dbg.c b/drivers/staging/mt7621-mmc/dbg.c
index 8bd4e30b8e91..539e589a9766 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);
-- 
2.16.1

_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel




[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux