diff options
author | Dmitry Shmidt <dimitrysh@google.com> | 2010-03-23 13:03:34 -0700 |
---|---|---|
committer | Dmitry Shmidt <dimitrysh@google.com> | 2010-03-23 13:03:34 -0700 |
commit | 3baca6cc248e0d9a852c25b214c92bc856ae03ea (patch) | |
tree | 08639d30eab9327785450f98dd5b3e63fbb50262 | |
parent | ebbf3c4d16536e401fdaf0389d592590c4bae83d (diff) | |
download | ti-3baca6cc248e0d9a852c25b214c92bc856ae03ea.tar.gz |
tnetw1271: Fix NULL pointer exception in Timer functionsHEADandroid-sdk-tools_r7android-sdk-tools_r6android-sdk-tools_r12android-sdk-adt_r12android-sdk-2.3.4_r1android-sdk-2.2_r2android-sdk-2.2_r1android-cts-2.3_r5android-cts-2.3_r4android-cts-2.3_r3android-cts-2.3_r2android-cts-2.3_r12android-cts-2.3_r11android-cts-2.3_r10android-cts-2.3_r1android-cts-2.2_r7android-cts-2.2_r6android-cts-2.2_r5android-cts-2.2_r4android-cts-2.2_r3android-cts-2.2_r2android-cts-2.2_r1android-adt-0.9.9android-adt-0.9.8android-2.3_r1android-2.3.7_r1android-2.3.6_r1android-2.3.6_r0.9android-2.3.5_r1android-2.3.4_r1android-2.3.4_r0.9android-2.3.3_r1aandroid-2.3.3_r1.1android-2.3.3_r1android-2.3.2_r1android-2.3.1_r1android-2.2_r1.3android-2.2_r1.2android-2.2_r1.1android-2.2_r1android-2.2.3_r1android-2.2.2_r1android-2.2.1_r2android-2.2.1_r1tools_r9tools_r8tools_r7mastermaingingerbread-releasegingerbread-mr4-releasegingerbreadfroyo-plus-aosp
Change-Id: I4108dd500304ad708b2244f9e1aa845f3f217221
Signed-off-by: Dmitry Shmidt <dimitrysh@google.com>
-rw-r--r-- | wilink_6_1/utils/timer.c | 80 |
1 files changed, 75 insertions, 5 deletions
diff --git a/wilink_6_1/utils/timer.c b/wilink_6_1/utils/timer.c index 0fbd726..e1795f0 100644 --- a/wilink_6_1/utils/timer.c +++ b/wilink_6_1/utils/timer.c @@ -125,19 +125,27 @@ TI_STATUS tmr_Destroy (TI_HANDLE hTimerModule) { TTimerModule *pTimerModule = (TTimerModule *)hTimerModule; + if (!pTimerModule) + { + WLAN_OS_REPORT (("tmr_Destroy(): ERROR - NULL timer!\n")); + return TI_NOK; + } + /* Alert if there are still timers that were not destroyed */ if (pTimerModule->uTimersCount) { WLAN_OS_REPORT (("tmr_Destroy(): ERROR - Destroying Timer module but not all timers were destroyed!!\n")); } - - /* Clear queues */ +#if 0 + /* Clear queues (critical section is used inside these functions) */ tmr_ClearInitQueue (hTimerModule); tmr_ClearOperQueue (hTimerModule); - - /* Destroy the module's queues */ +#endif + /* Destroy the module's queues (protect in critical section)) */ + context_EnterCriticalSection (pTimerModule->hContext); que_Destroy (pTimerModule->hInitQueue); que_Destroy (pTimerModule->hOperQueue); + context_LeaveCriticalSection (pTimerModule->hContext); /* free module object */ os_memoryFree (pTimerModule->hOs, pTimerModule, sizeof(TTimerModule)); @@ -158,6 +166,12 @@ TI_STATUS tmr_Free(TI_HANDLE hTimerModule) { TTimerModule *pTimerModule = (TTimerModule *)hTimerModule; + if (!pTimerModule) + { + WLAN_OS_REPORT (("tmr_Free(): ERROR - NULL timer!\n")); + return TI_NOK; + } + /* free module object */ os_memoryFree (pTimerModule->hOs, pTimerModule, sizeof(TTimerModule)); @@ -221,6 +235,12 @@ void tmr_Init (TI_HANDLE hTimerModule, TI_HANDLE hOs, TI_HANDLE hReport, TI_HAND TTimerModule *pTimerModule = (TTimerModule *)hTimerModule; TI_UINT32 uNodeHeaderOffset; + if (!pTimerModule) + { + WLAN_OS_REPORT (("tmr_Init(): ERROR - NULL timer!\n")); + return; + } + pTimerModule->hOs = hOs; pTimerModule->hReport = hReport; pTimerModule->hContext = hContext; @@ -272,6 +292,12 @@ void tmr_UpdateDriverState (TI_HANDLE hTimerModule, TI_BOOL bOperState) TTimerModule *pTimerModule = (TTimerModule *)hTimerModule; TTimerInfo *pTimerInfo; /* The timer handle */ + if (!pTimerModule) + { + WLAN_OS_REPORT (("tmr_UpdateDriverState(): ERROR - NULL timer!\n")); + return; + } + /* Enter critical section */ context_EnterCriticalSection (pTimerModule->hContext); @@ -331,6 +357,12 @@ TI_HANDLE tmr_CreateTimer (TI_HANDLE hTimerModule) TTimerModule *pTimerModule = (TTimerModule *)hTimerModule; /* The timer module handle */ TTimerInfo *pTimerInfo; /* The created timer handle */ + if (!pTimerModule) + { + WLAN_OS_REPORT (("tmr_CreateTimer(): ERROR - NULL timer!\n")); + return NULL; + } + /* Allocate timer object */ pTimerInfo = os_memoryAlloc (pTimerModule->hOs, sizeof(TTimerInfo)); if (!pTimerInfo) @@ -376,8 +408,16 @@ TI_STATUS tmr_DestroyTimer (TI_HANDLE hTimerInfo) TTimerModule *pTimerModule; /* The timer module handle */ if (!pTimerInfo) + { return TI_NOK; + } pTimerModule = (TTimerModule *)pTimerInfo->hTimerModule; + if (!pTimerModule) + { + WLAN_OS_REPORT (("tmr_DestroyTimer(): ERROR - NULL timer!\n")); + return TI_NOK; + } + /* Free the OS-API timer */ if (pTimerInfo->hOsTimerObj) { os_timerDestroy (pTimerModule->hOs, pTimerInfo->hOsTimerObj); @@ -418,6 +458,12 @@ void tmr_StartTimer (TI_HANDLE hTimerInfo, TTimerInfo *pTimerInfo = (TTimerInfo *)hTimerInfo; /* The timer handle */ TTimerModule *pTimerModule = (TTimerModule *)pTimerInfo->hTimerModule; /* The timer module handle */ + if (!pTimerModule) + { + WLAN_OS_REPORT (("tmr_StartTimer(): ERROR - NULL timer!\n")); + return; + } + /* Save the timer parameters. */ pTimerInfo->fExpiryCbFunc = fExpiryCbFunc; pTimerInfo->hExpiryCbHndl = hExpiryCbHndl; @@ -449,6 +495,12 @@ void tmr_StopTimer (TI_HANDLE hTimerInfo) TTimerInfo *pTimerInfo = (TTimerInfo *)hTimerInfo; /* The timer handle */ TTimerModule *pTimerModule = (TTimerModule *)pTimerInfo->hTimerModule; /* The timer module handle */ + if (!pTimerModule) + { + WLAN_OS_REPORT (("tmr_StopTimer(): ERROR - NULL timer!\n")); + return; + } + /* Stop OS-API timer running */ os_timerStop(pTimerModule->hOs, pTimerInfo->hOsTimerObj); @@ -473,7 +525,13 @@ void tmr_StopTimer (TI_HANDLE hTimerInfo) void tmr_GetExpiry (TI_HANDLE hTimerInfo) { TTimerInfo *pTimerInfo = (TTimerInfo *)hTimerInfo; /* The timer handle */ - TTimerModule *pTimerModule = (TTimerModule *)pTimerInfo->hTimerModule; /* The timer module handle */ + TTimerModule *pTimerModule = (TTimerModule *)pTimerInfo->hTimerModule; /* The timer module handle */ + + if (!pTimerModule) + { + WLAN_OS_REPORT (("tmr_GetExpiry(): ERROR - NULL timer!\n")); + return; + } /* Enter critical section */ context_EnterCriticalSection (pTimerModule->hContext); @@ -525,6 +583,12 @@ void tmr_HandleExpiry (TI_HANDLE hTimerModule) TTimerInfo *pTimerInfo; /* The timer handle */ TI_BOOL bTwdInitOccured; /* Indicates if TWD init occured since timer start */ + if (!pTimerModule) + { + WLAN_OS_REPORT (("tmr_HandleExpiry(): ERROR - NULL timer!\n")); + return; + } + while (1) { /* Enter critical section */ @@ -588,6 +652,12 @@ void tmr_PrintModule (TI_HANDLE hTimerModule) { TTimerModule *pTimerModule = (TTimerModule *)hTimerModule; + if (!pTimerModule) + { + WLAN_OS_REPORT (("tmr_PrintModule(): ERROR - NULL timer!\n")); + return; + } + /* Print module parameters */ WLAN_OS_REPORT(("tmr_PrintModule(): uContextId=%d, bOperState=%d, uTwdInitCount=%d, uTimersCount=%d\n", pTimerModule->uContextId, pTimerModule->bOperState, |