summaryrefslogtreecommitdiff
path: root/software/octdeviceapi/oct6100api/oct6100_api/oct6100_chip_open.c
diff options
context:
space:
mode:
authorMatthew Fredrickson <creslin@digium.com>2007-05-31 17:55:10 +0000
committerTzafrir Cohen <tzafrir.cohen@xorcom.com>2011-02-27 21:09:15 +0200
commitd02af324a13c3e9ab050ba0b8f72a738bd537048 (patch)
treeb74d18ea353a86f32e34a9d4faed423587cee92d /software/octdeviceapi/oct6100api/oct6100_api/oct6100_chip_open.c
parentef7d0400b4b0ea8ad3bf8e3133c3fe5d9cb39fa7 (diff)
Fix stack overflow and other memory corruption problems with FC6 on Dell 2950
git-svn-id: http://svn.asterisk.org/svn/octasic_api/oct612x/trunk@25 537310ab-6354-42db-a3cc-247b777f7be6
Diffstat (limited to 'software/octdeviceapi/oct6100api/oct6100_api/oct6100_chip_open.c')
-rw-r--r--software/octdeviceapi/oct6100api/oct6100_api/oct6100_chip_open.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/software/octdeviceapi/oct6100api/oct6100_api/oct6100_chip_open.c b/software/octdeviceapi/oct6100api/oct6100_api/oct6100_chip_open.c
index 3f4baed..36a07c4 100644
--- a/software/octdeviceapi/oct6100api/oct6100_api/oct6100_chip_open.c
+++ b/software/octdeviceapi/oct6100api/oct6100_api/oct6100_chip_open.c
@@ -33,6 +33,8 @@ $Octasic_Revision: 336 $
/***************************** INCLUDE FILES *******************************/
+#include <linux/slab.h>
+
#include "octdef.h"
#include "oct6100api/oct6100_defines.h"
@@ -272,7 +274,7 @@ UINT32 Oct6100ChipOpen(
tPOCT6100_INSTANCE_API f_pApiInstance,
tPOCT6100_CHIP_OPEN f_pChipOpen )
{
- tOCT6100_API_INSTANCE_SIZES InstanceSizes;
+ tOCT6100_API_INSTANCE_SIZES *InstanceSizes;
UINT32 ulStructSize;
UINT32 ulResult;
UINT32 ulTempVar;
@@ -310,13 +312,20 @@ UINT32 Oct6100ChipOpen(
if ( ulResult != cOCT6100_ERR_OK )
return ulResult;
+ InstanceSizes = kmalloc(sizeof(tOCT6100_API_INSTANCE_SIZES), GFP_KERNEL);
+ if (!InstanceSizes)
+ return cOCT6100_ERR_FATAL_0;
/* Calculate the amount of memory needed for the API instance structure. */
- ulResult = Oct6100ApiCalculateInstanceSizes( f_pChipOpen, &InstanceSizes );
- if ( ulResult != cOCT6100_ERR_OK )
+ ulResult = Oct6100ApiCalculateInstanceSizes( f_pChipOpen, InstanceSizes );
+ if ( ulResult != cOCT6100_ERR_OK ) {
+ kfree(InstanceSizes);
return ulResult;
+ }
/* Allocate the memory for the API instance structure internal pointers. */
- ulResult = Oct6100ApiAllocateInstanceMemory( f_pApiInstance, &InstanceSizes );
+ ulResult = Oct6100ApiAllocateInstanceMemory( f_pApiInstance, InstanceSizes );
+ kfree(InstanceSizes);
+
if ( ulResult != cOCT6100_ERR_OK )
return ulResult;