aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesper Juhl <jj@chaosbits.net>2012-04-11 18:35:46 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2012-04-12 17:34:31 -0400
commit17b7e1ba1e2ecc9a09f5e154e555accd2a2eaedf (patch)
tree7ecf4e5154c5f52d08f692b66c81c0d631e56990
parent62d2feb9803f18c4e3c8a1a2c7e30a54df8a1d72 (diff)
staging: vt6656: Don't leak memory in drivers/staging/vt6656/ioctl.c::private_ioctl()
If copy_to_user() fails in the WLAN_CMD_GET_NODE_LIST case of the switch in drivers/staging/vt6656/ioctl.c::private_ioctl() we'll leak the memory allocated to 'pNodeList'. Fix that by kfree'ing the memory in the failure case. Also remove a pointless cast (to type 'PSNodeList') of a kmalloc() return value - kmalloc() returns a void pointer that is implicitly converted, so there is no need for an explicit cast. Signed-off-by: Jesper Juhl <jj@chaosbits.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/staging/vt6656/ioctl.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/drivers/staging/vt6656/ioctl.c b/drivers/staging/vt6656/ioctl.c
index 1463d76895f0..d59456c29df1 100644
--- a/drivers/staging/vt6656/ioctl.c
+++ b/drivers/staging/vt6656/ioctl.c
@@ -565,7 +565,7 @@ int private_ioctl(PSDevice pDevice, struct ifreq *rq)
565 result = -ENOMEM; 565 result = -ENOMEM;
566 break; 566 break;
567 } 567 }
568 pNodeList = (PSNodeList)kmalloc(sizeof(SNodeList) + (sNodeList.uItem * sizeof(SNodeItem)), (int)GFP_ATOMIC); 568 pNodeList = kmalloc(sizeof(SNodeList) + (sNodeList.uItem * sizeof(SNodeItem)), (int)GFP_ATOMIC);
569 if (pNodeList == NULL) { 569 if (pNodeList == NULL) {
570 result = -ENOMEM; 570 result = -ENOMEM;
571 break; 571 break;
@@ -601,6 +601,7 @@ int private_ioctl(PSDevice pDevice, struct ifreq *rq)
601 } 601 }
602 } 602 }
603 if (copy_to_user(pReq->data, pNodeList, sizeof(SNodeList) + (sNodeList.uItem * sizeof(SNodeItem)))) { 603 if (copy_to_user(pReq->data, pNodeList, sizeof(SNodeList) + (sNodeList.uItem * sizeof(SNodeItem)))) {
604 kfree(pNodeList);
604 result = -EFAULT; 605 result = -EFAULT;
605 break; 606 break;
606 } 607 }