Skip to contentSkip to conversation

ip2: return -EFAULT on copy_to_user errors

PATCH In review Dan Carpenter 1 participant 1 message Aug 12, 2010

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 2/2 ip2: return -EFAULT on copy_to_user errors

copy_to_user() returns the number of bytes remaining but we want to return a negative error code on errors.

drivers/char/ip2/ip2main.c +2 -0
index 8fa041e..d4b71e8 100644
@@ -2930,6 +2930,8 @@ ip2_ipl_ioctl (struct file *pFile, UINT cmd, ULONG arg )
 				if ( pCh )
 				{
 					rc = copy_to_user(argp, pCh, sizeof(i2ChanStr));
+					if (rc)
+						rc = -EFAULT;
 				} else {
 					rc = -ENODEV;
 				}