aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorThomas Meyer <thomas@m3y3r.de>2012-01-22 12:29:51 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2012-02-08 20:22:16 -0500
commit2d9ebe77b7665a431a9816eff3eb588e05176dfa (patch)
treefe058d2e0219233017efe91d897350fda228de95 /drivers
parent5cf4d6b936ca21f67aa763dd0d3f8fdd9873b22c (diff)
Staging: bcm: Use memdup_user rather than duplicating its implementation
This is a little bit restricted to reduce false positives The semantic patch that makes this change is available in scripts/coccinelle/api/memdup_user.cocci. More information about semantic patching is available at http://coccinelle.lip6.fr/ Signed-off-by: Thomas Meyer <thomas@m3y3r.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/staging/bcm/Bcmchar.c37
1 files changed, 12 insertions, 25 deletions
diff --git a/drivers/staging/bcm/Bcmchar.c b/drivers/staging/bcm/Bcmchar.c
index 8bf3f575160f..cf3059216958 100644
--- a/drivers/staging/bcm/Bcmchar.c
+++ b/drivers/staging/bcm/Bcmchar.c
@@ -728,14 +728,10 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg)
728 if (IoBuffer.InputLength > MAX_CNTL_PKT_SIZE) 728 if (IoBuffer.InputLength > MAX_CNTL_PKT_SIZE)
729 return -EINVAL; 729 return -EINVAL;
730 730
731 pvBuffer = kmalloc(IoBuffer.InputLength, GFP_KERNEL); 731 pvBuffer = memdup_user(IoBuffer.InputBuffer,
732 if (!pvBuffer) 732 IoBuffer.InputLength);
733 return -ENOMEM; 733 if (IS_ERR(pvBuffer))
734 734 return PTR_ERR(pvBuffer);
735 if (copy_from_user(pvBuffer, IoBuffer.InputBuffer, IoBuffer.InputLength)) {
736 kfree(pvBuffer);
737 return -EFAULT;
738 }
739 735
740 down(&Adapter->LowPowerModeSync); 736 down(&Adapter->LowPowerModeSync);
741 Status = wait_event_interruptible_timeout(Adapter->lowpower_mode_wait_queue, 737 Status = wait_event_interruptible_timeout(Adapter->lowpower_mode_wait_queue,
@@ -1140,15 +1136,10 @@ cntrlEnd:
1140 if (IoBuffer.InputLength < sizeof(ULONG) * 2) 1136 if (IoBuffer.InputLength < sizeof(ULONG) * 2)
1141 return -EINVAL; 1137 return -EINVAL;
1142 1138
1143 pvBuffer = kmalloc(IoBuffer.InputLength, GFP_KERNEL); 1139 pvBuffer = memdup_user(IoBuffer.InputBuffer,
1144 if (!pvBuffer) 1140 IoBuffer.InputLength);
1145 return -ENOMEM; 1141 if (IS_ERR(pvBuffer))
1146 1142 return PTR_ERR(pvBuffer);
1147 /* Get WrmBuffer structure */
1148 if (copy_from_user(pvBuffer, IoBuffer.InputBuffer, IoBuffer.InputLength)) {
1149 kfree(pvBuffer);
1150 return -EFAULT;
1151 }
1152 1143
1153 pBulkBuffer = (PBULKWRM_BUFFER)pvBuffer; 1144 pBulkBuffer = (PBULKWRM_BUFFER)pvBuffer;
1154 1145
@@ -1310,14 +1301,10 @@ cntrlEnd:
1310 return STATUS_FAILURE; 1301 return STATUS_FAILURE;
1311 } 1302 }
1312 1303
1313 pReadData = kzalloc(stNVMReadWrite.uiNumBytes, GFP_KERNEL); 1304 pReadData = memdup_user(stNVMReadWrite.pBuffer,
1314 if (!pReadData) 1305 stNVMReadWrite.uiNumBytes);
1315 return -ENOMEM; 1306 if (IS_ERR(pReadData))
1316 1307 return PTR_ERR(pReadData);
1317 if (copy_from_user(pReadData, stNVMReadWrite.pBuffer, stNVMReadWrite.uiNumBytes)) {
1318 kfree(pReadData);
1319 return -EFAULT;
1320 }
1321 1308
1322 do_gettimeofday(&tv0); 1309 do_gettimeofday(&tv0);
1323 if (IOCTL_BCM_NVM_READ == cmd) { 1310 if (IOCTL_BCM_NVM_READ == cmd) {