From d02af324a13c3e9ab050ba0b8f72a738bd537048 Mon Sep 17 00:00:00 2001 From: Matthew Fredrickson Date: Thu, 31 May 2007 17:55:10 +0000 Subject: 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 --- .../oct6100api/oct6100_api/oct6100_chip_open.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'software/octdeviceapi/oct6100api/oct6100_api/oct6100_chip_open.c') 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 + #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; -- cgit v1.2.3