wlan: Multiple Memory Leaks @File wlan_qct_wdi.c
In Multiple messages, error conditions are not taken care
properly which causes the memory leak
CRs-fixed: 451540
Change-Id: Ief4eb8170379adf72544a7b8cb5f7fc32349d44c
(cherry picked from commit 82a5af15221742c9e6ea7c45a2a64e5da9f8ffeb)
diff --git a/CORE/WDI/CP/src/wlan_qct_wdi.c b/CORE/WDI/CP/src/wlan_qct_wdi.c
index fd19834..838d2d8 100644
--- a/CORE/WDI/CP/src/wlan_qct_wdi.c
+++ b/CORE/WDI/CP/src/wlan_qct_wdi.c
@@ -6526,7 +6526,7 @@
WPAL_TRACE( eWLAN_MODULE_DAL_CTRL, eWLAN_PAL_TRACE_LEVEL_WARN,
"%s: Invalid parameters", __func__);
WDI_ASSERT(0);
- return WDI_STATUS_E_FAILURE;
+ goto failRequest;
}
/*-----------------------------------------------------------------------
@@ -6541,7 +6541,7 @@
"Unable to get send buffer in stop req %x %x %x",
pEventData, pwdiStopParams, wdiStopRspCb);
WDI_ASSERT(0);
- return WDI_STATUS_E_FAILURE;
+ goto failRequest;
}
/*-----------------------------------------------------------------------
@@ -6572,7 +6572,7 @@
"WDI Init failed to reset power state event");
WDI_ASSERT(0);
- return VOS_STATUS_E_FAILURE;
+ goto fail;
}
/* Stop Transport Driver, DXE */
status = WDTS_SetPowerState(pWDICtx, WDTS_POWER_STATE_DOWN, WDI_SetPowerStateCb);
@@ -6581,7 +6581,7 @@
WPAL_TRACE(eWLAN_MODULE_DAL_CTRL, eWLAN_PAL_TRACE_LEVEL_FATAL,
"WDTS_SetPowerState returned with status %d when trying to notify DTS that host is entering Power Down state\n", status);
WDI_ASSERT(0);
- return WDI_STATUS_E_FAILURE;
+ goto fail;
}
/*
* Wait for the event to be set once the ACK comes back from DXE
@@ -6594,7 +6594,7 @@
"WDI Init failed to wait on an event");
WDI_ASSERT(0);
- return VOS_STATUS_E_FAILURE;
+ goto fail;
}
}
@@ -6604,6 +6604,14 @@
return WDI_SendMsg( pWDICtx, pSendBuffer, usSendSize,
wdiStopRspCb, pEventData->pUserData, WDI_STOP_RESP);
+fail:
+ // Release the message buffer so we don't leak
+ wpalMemoryFree(pSendBuffer);
+
+failRequest:
+ //WDA should have failure check to avoid the memory leak
+ return WDI_STATUS_E_FAILURE;
+
}/*WDI_ProcessStopReq*/
/**
@@ -7912,6 +7920,7 @@
WPAL_TRACE( eWLAN_MODULE_DAL_CTRL, eWLAN_PAL_TRACE_LEVEL_WARN,
"This station does not exist in the WDI Station Table %d");
wpalMutexRelease(&pWDICtx->wptMutex);
+ wpalMemoryFree(pSendBuffer);
return WDI_STATUS_E_FAILURE;
}
@@ -11882,7 +11891,7 @@
WPAL_TRACE( eWLAN_MODULE_DAL_CTRL, eWLAN_PAL_TRACE_LEVEL_WARN,
"%s: Invalid parameters", __func__);
WDI_ASSERT(0);
- return WDI_STATUS_E_FAILURE;
+ goto failRequest;
}
/*-----------------------------------------------------------------------
@@ -11898,7 +11907,7 @@
"Unable to get send buffer in Enter IMPS req %x %x",
pEventData, wdiEnterImpsRspCb);
WDI_ASSERT(0);
- return WDI_STATUS_E_FAILURE;
+ goto failRequest;
}
/* Reset the event to be not signalled */
@@ -11909,7 +11918,7 @@
"WDI Init failed to reset an event");
WDI_ASSERT(0);
- return VOS_STATUS_E_FAILURE;
+ goto fail;
}
// notify DTS that we are entering IMPS
@@ -11918,7 +11927,7 @@
WPAL_TRACE(eWLAN_MODULE_DAL_CTRL, eWLAN_PAL_TRACE_LEVEL_FATAL,
"WDTS_SetPowerState returned with status %d when trying to notify DTS that host is entering IMPS\n", wptStatus);
WDI_ASSERT(0);
- return WDI_STATUS_E_FAILURE;
+ goto fail;
}
/*
@@ -11932,7 +11941,7 @@
"WDI Init failed to wait on an event");
WDI_ASSERT(0);
- return VOS_STATUS_E_FAILURE;
+ goto fail;
}
/*-------------------------------------------------------------------------
@@ -11940,6 +11949,14 @@
-------------------------------------------------------------------------*/
return WDI_SendMsg( pWDICtx, pSendBuffer, usSendSize,
wdiEnterImpsRspCb, pEventData->pUserData, WDI_ENTER_IMPS_RESP);
+
+fail:
+ // Release the message buffer so we don't leak
+ wpalMemoryFree(pSendBuffer);
+
+failRequest:
+ //WDA should have failure check to avoid the memory leak
+ return WDI_STATUS_E_FAILURE;
}/*WDI_ProcessEnterImpsReq*/
/**
@@ -12037,7 +12054,7 @@
WPAL_TRACE( eWLAN_MODULE_DAL_CTRL, eWLAN_PAL_TRACE_LEVEL_WARN,
"%s: Invalid parameters", __func__);
WDI_ASSERT(0);
- return WDI_STATUS_E_FAILURE;
+ goto failRequest;
}
/*-----------------------------------------------------------------------
@@ -12053,7 +12070,7 @@
"Unable to get send buffer in Enter BMPS req %x %x %x",
pEventData, pwdiEnterBmpsReqParams, wdiEnterBmpsRspCb);
WDI_ASSERT(0);
- return WDI_STATUS_E_FAILURE;
+ goto failRequest;
}
/* Reset the event to be not signalled */
@@ -12064,7 +12081,7 @@
"WDI Init failed to reset an event");
WDI_ASSERT(0);
- return VOS_STATUS_E_FAILURE;
+ goto fail;
}
// notify DTS that we are entering BMPS
@@ -12074,7 +12091,7 @@
WPAL_TRACE(eWLAN_MODULE_DAL_CTRL, eWLAN_PAL_TRACE_LEVEL_FATAL,
"WDTS_SetPowerState returned with status %d when trying to notify DTS that we are entering BMPS\n", wptStatus);
WDI_ASSERT(0);
- return WDI_STATUS_E_FAILURE;
+ goto fail;
}
/*
@@ -12088,7 +12105,7 @@
"WDI Init failed to wait on an event");
WDI_ASSERT(0);
- return VOS_STATUS_E_FAILURE;
+ goto fail;
}
pWDICtx->bInBmps = eWLAN_PAL_TRUE;
@@ -12115,6 +12132,14 @@
-------------------------------------------------------------------------*/
return WDI_SendMsg( pWDICtx, pSendBuffer, usSendSize,
wdiEnterBmpsRspCb, pEventData->pUserData, WDI_ENTER_BMPS_RESP);
+
+fail:
+ // Release the message buffer so we don't leak
+ wpalMemoryFree(pSendBuffer);
+
+failRequest:
+ //WDA should have failure check to avoid the memory leak
+ return WDI_STATUS_E_FAILURE;
}/*WDI_ProcessEnterBmpsReq*/
/**
@@ -12829,7 +12854,7 @@
WPAL_TRACE( eWLAN_MODULE_DAL_CTRL, eWLAN_PAL_TRACE_LEVEL_WARN,
"%s: Invalid parameters", __func__);
WDI_ASSERT(0);
- return WDI_STATUS_E_FAILURE;
+ goto failRequest;
}
/*-----------------------------------------------------------------------
@@ -12845,7 +12870,7 @@
"Unable to get send buffer in host offload req %x %x %x",
pEventData, pwdiHostOffloadParams, wdiHostOffloadCb);
WDI_ASSERT(0);
- return WDI_STATUS_E_FAILURE;
+ goto failRequest;
}
ucCurrentBSSSesIdx = WDI_FindAssocSession( pWDICtx,
@@ -12855,7 +12880,7 @@
{
WPAL_TRACE( eWLAN_MODULE_DAL_CTRL, eWLAN_PAL_TRACE_LEVEL_ERROR,
" %s : Association for this BSSID does not exist",__func__);
- return WDI_STATUS_E_FAILURE;
+ goto fail;
}
hostOffloadParams.offloadType = pwdiHostOffloadParams->wdiHostOffloadInfo.ucOffloadType;
@@ -12934,6 +12959,14 @@
-------------------------------------------------------------------------*/
return WDI_SendMsg( pWDICtx, pSendBuffer, usSendSize,
wdiHostOffloadCb, pEventData->pUserData, WDI_HOST_OFFLOAD_RESP);
+
+fail:
+ // Release the message buffer so we don't leak
+ wpalMemoryFree(pSendBuffer);
+
+failRequest:
+ //WDA should have failure check to avoid the memory leak
+ return WDI_STATUS_E_FAILURE;
}/*WDI_ProcessHostOffloadReq*/
/**
@@ -12974,7 +13007,7 @@
WPAL_TRACE( eWLAN_MODULE_DAL_CTRL, eWLAN_PAL_TRACE_LEVEL_ERROR,
"Invalid parameters in Keep Alive req");
WDI_ASSERT(0);
- return WDI_STATUS_E_FAILURE;
+ goto failRequest;
}
/*-----------------------------------------------------------------------
@@ -12990,7 +13023,7 @@
"Unable to get send buffer in keep alive req %x %x %x",
pEventData, pwdiKeepAliveParams, wdiKeepAliveCb);
WDI_ASSERT(0);
- return WDI_STATUS_E_FAILURE;
+ goto failRequest;
}
ucCurrentBSSSesIdx = WDI_FindAssocSession( pWDICtx,
@@ -13000,7 +13033,7 @@
{
WPAL_TRACE( eWLAN_MODULE_DAL_CTRL, eWLAN_PAL_TRACE_LEVEL_ERROR,
" %s : Association for this BSSID does not exist",__func__);
- return WDI_STATUS_E_FAILURE;
+ goto fail;
}
keepAliveReq.packetType = pwdiKeepAliveParams->wdiKeepAliveInfo.ucPacketType;
@@ -13042,6 +13075,14 @@
-------------------------------------------------------------------------*/
return WDI_SendMsg( pWDICtx, pSendBuffer, usSendSize,
wdiKeepAliveCb, pEventData->pUserData, WDI_KEEP_ALIVE_RESP);
+
+fail:
+ // Release the message buffer so we don't leak
+ wpalMemoryFree(pSendBuffer);
+
+failRequest:
+ //WDA should have failure check to avoid the memory leak
+ return WDI_STATUS_E_FAILURE;
}/*WDI_ProcessKeepAliveReq*/
@@ -13083,7 +13124,7 @@
WPAL_TRACE( eWLAN_MODULE_DAL_CTRL, eWLAN_PAL_TRACE_LEVEL_WARN,
"%s: Invalid parameters", __func__);
WDI_ASSERT(0);
- return WDI_STATUS_E_FAILURE;
+ goto failRequest;
}
/*-----------------------------------------------------------------------
@@ -13099,7 +13140,7 @@
"Unable to get send buffer in Wowl add bc ptrn req %x %x %x",
pEventData, pwdiWowlAddBcPtrnParams, wdiWowlAddBcPtrnCb);
WDI_ASSERT(0);
- return WDI_STATUS_E_FAILURE;
+ goto failRequest;
}
ucCurrentBSSSesIdx = WDI_FindAssocSession( pWDICtx,
@@ -13109,7 +13150,7 @@
{
WPAL_TRACE( eWLAN_MODULE_DAL_CTRL, eWLAN_PAL_TRACE_LEVEL_ERROR,
" %s : Association for this BSSID does not exist",__func__);
- return WDI_STATUS_E_FAILURE;
+ goto fail;
}
wowlAddBcPtrnReq.ucPatternId =
@@ -13161,6 +13202,13 @@
-------------------------------------------------------------------------*/
return WDI_SendMsg( pWDICtx, pSendBuffer, usSendSize,
wdiWowlAddBcPtrnCb, pEventData->pUserData, WDI_WOWL_ADD_BC_PTRN_RESP);
+fail:
+ // Release the message buffer so we don't leak
+ wpalMemoryFree(pSendBuffer);
+
+failRequest:
+ //WDA should have failure check to avoid the memory leak
+ return WDI_STATUS_E_FAILURE;
}/*WDI_ProcessWowlAddBcPtrnReq*/
/**
@@ -13200,7 +13248,7 @@
WPAL_TRACE( eWLAN_MODULE_DAL_CTRL, eWLAN_PAL_TRACE_LEVEL_WARN,
"%s: Invalid parameters", __func__);
WDI_ASSERT(0);
- return WDI_STATUS_E_FAILURE;
+ goto failRequest;
}
/*-----------------------------------------------------------------------
@@ -13216,7 +13264,7 @@
"Unable to get send buffer in Wowl del bc ptrn req %x %x %x",
pEventData, pwdiWowlDelBcPtrnParams, wdiWowlDelBcPtrnCb);
WDI_ASSERT(0);
- return WDI_STATUS_E_FAILURE;
+ goto failRequest;
}
ucCurrentBSSSesIdx = WDI_FindAssocSession( pWDICtx,
@@ -13226,7 +13274,7 @@
{
WPAL_TRACE( eWLAN_MODULE_DAL_CTRL, eWLAN_PAL_TRACE_LEVEL_ERROR,
" %s : Association for this BSSID does not exist",__func__);
- return WDI_STATUS_E_FAILURE;
+ goto fail;
}
wowlDelBcPtrnReq.ucPatternId =
@@ -13246,6 +13294,14 @@
-------------------------------------------------------------------------*/
return WDI_SendMsg( pWDICtx, pSendBuffer, usSendSize,
wdiWowlDelBcPtrnCb, pEventData->pUserData, WDI_WOWL_DEL_BC_PTRN_RESP);
+
+fail:
+ // Release the message buffer so we don't leak
+ wpalMemoryFree(pSendBuffer);
+
+failRequest:
+ //WDA should have failure check to avoid the memory leak
+ return WDI_STATUS_E_FAILURE;
}/*WDI_ProcessWowlDelBcPtrnReq*/
/**
@@ -24881,7 +24937,7 @@
WPAL_TRACE( eWLAN_MODULE_DAL_CTRL, eWLAN_PAL_TRACE_LEVEL_WARN,
"%s: Invalid parameters", __func__);
WDI_ASSERT(0);
- return WDI_STATUS_E_FAILURE;
+ goto failRequest;
}
/*-----------------------------------------------------------------------
@@ -24896,7 +24952,7 @@
"Unable to get send buffer in GTK offload req %x %x %x",
pEventData, pwdiGtkOffloadReqMsg, wdiGtkOffloadCb);
WDI_ASSERT(0);
- return WDI_STATUS_E_FAILURE;
+ goto failRequest;
}
//
@@ -24909,7 +24965,7 @@
{
WPAL_TRACE( eWLAN_MODULE_DAL_CTRL, eWLAN_PAL_TRACE_LEVEL_ERROR,
" %s : Association for this BSSID does not exist", __func__);
- return WDI_STATUS_E_FAILURE;
+ goto fail;
}
gtkOffloadReqParams.bssIdx = pBSSSes->ucBSSIdx;
@@ -24934,6 +24990,14 @@
-------------------------------------------------------------------------*/
return WDI_SendMsg( pWDICtx, pSendBuffer, usSendSize,
wdiGtkOffloadCb, pEventData->pUserData, WDI_GTK_OFFLOAD_RESP);
+
+fail:
+ // Release the message buffer so we don't leak
+ wpalMemoryFree(pSendBuffer);
+
+failRequest:
+ //WDA should have failure check to avoid the memory leak
+ return WDI_STATUS_E_FAILURE;
}
@@ -24972,7 +25036,7 @@
WPAL_TRACE( eWLAN_MODULE_DAL_CTRL, eWLAN_PAL_TRACE_LEVEL_WARN,
"%s: Invalid parameters", __func__);
WDI_ASSERT(0);
- return WDI_STATUS_E_FAILURE;
+ goto failRequest;
}
/*-----------------------------------------------------------------------
@@ -24987,7 +25051,7 @@
"Unable to get send buffer in WDI_ProcessGTKOffloadGetInfoReq() %x %x %x",
pEventData, pwdiGtkOffloadGetInfoReqMsg, wdiGtkOffloadGetInfoCb);
WDI_ASSERT(0);
- return WDI_STATUS_E_FAILURE;
+ goto failRequest;
}
ucCurrentSessionId = WDI_FindAssocSession( pWDICtx,
pwdiGtkOffloadGetInfoReqMsg->WDI_GtkOffloadGetInfoReqParams.bssId,
@@ -24996,7 +25060,7 @@
{
WPAL_TRACE( eWLAN_MODULE_DAL_CTRL, eWLAN_PAL_TRACE_LEVEL_ERROR,
" %s : Association for this BSSID does not exist",__func__);
- return WDI_STATUS_E_FAILURE;
+ goto fail;
}
halGtkOffloadGetInfoReqParams.bssIdx = pBSSSes->ucBSSIdx;
@@ -25015,6 +25079,13 @@
-------------------------------------------------------------------------*/
return WDI_SendMsg( pWDICtx, pSendBuffer, usSendSize,
wdiGtkOffloadGetInfoCb, pEventData->pUserData, WDI_GTK_OFFLOAD_GETINFO_RESP);
+fail:
+ // Release the message buffer so we don't leak
+ wpalMemoryFree(pSendBuffer);
+
+failRequest:
+ //WDA should have failure check to avoid the memory leak
+ return WDI_STATUS_E_FAILURE;
}
/**