summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMartijn Coenen <maco@google.com>2012-01-20 18:05:36 -0800
committerMartijn Coenen <maco@google.com>2012-01-20 18:05:36 -0800
commit3a53a1e3754df0e5d77a6549a620d570acacbae4 (patch)
tree82656bb202f740993dd66fa00ab7a52b655db294 /src
parent78b4597397765d73b00995165ee972bbf2e36882 (diff)
downloadexternal_libnfc-nxp-3a53a1e3754df0e5d77a6549a620d570acacbae4.zip
external_libnfc-nxp-3a53a1e3754df0e5d77a6549a620d570acacbae4.tar.gz
external_libnfc-nxp-3a53a1e3754df0e5d77a6549a620d570acacbae4.tar.bz2
Don't overwrite psUpperLayerContext when reconfiguring the SE.
This fixes one of the crashes occuring when turning the screen off during p2p transfers. One remaining. Change-Id: I3e45be9b8f4be40350ba4dd9db7e596631206bd1
Diffstat (limited to 'src')
-rw-r--r--src/phHal4Nfc_Emulation.c4
-rw-r--r--src/phLibNfc_SE.c99
2 files changed, 49 insertions, 54 deletions
diff --git a/src/phHal4Nfc_Emulation.c b/src/phHal4Nfc_Emulation.c
index b231f1e..6bb60e2 100644
--- a/src/phHal4Nfc_Emulation.c
+++ b/src/phHal4Nfc_Emulation.c
@@ -140,8 +140,6 @@ NFCSTATUS phHal4Nfc_Switch_SMX_Mode(
}
else
{
- /* Register Upper layer context */
- Hal4Ctxt->sUpperLayerInfo.psUpperLayerCtxt = pContext;
/* Switch request to Wired mode */
if(eSmartMx_Wired == smx_mode)
{
@@ -270,8 +268,6 @@ NFCSTATUS phHal4Nfc_Switch_Swp_Mode(
}
else
{
- /* Register Upper layer context */
- Hal4Ctxt->sUpperLayerInfo.psUpperLayerCtxt = pContext;
/*Switch mode to On or off*/
CfgStatus = phHciNfc_Switch_SwpMode(
Hal4Ctxt->psHciHandle,
diff --git a/src/phLibNfc_SE.c b/src/phLibNfc_SE.c
index 968c239..2cdb24e 100644
--- a/src/phLibNfc_SE.c
+++ b/src/phLibNfc_SE.c
@@ -665,81 +665,80 @@ NFCSTATUS phLibNfc_SE_SetMode ( phLibNfc_Handle hSE_Handle,
*/
STATIC void phLibNfc_SE_SetMode_cb(void *context, NFCSTATUS status)
{
- pphLibNfc_LibContext_t pLibContext=(pphLibNfc_LibContext_t)context;
+ /* Note that we don't use the passed in context here;
+ * the reason is that there are race-conditions around
+ * the place where this context is stored (mostly in combination
+ * with LLCP), and we may actually get the wrong context.
+ * Since this callback always uses the global context
+ * we don't need the passed in context anyway.
+ */
+ pphLibNfc_LibContext_t pLibContext=gpphLibContext;
pphLibNfc_SE_SetModeRspCb_t pUpperLayerCb=NULL;
void *pUpperContext=NULL;
phLibNfc_Handle hSeHandle=0;
uint8_t TempState=FALSE;
- if(pLibContext != gpphLibContext)
+ if(eLibNfcHalStateShutdown == gpphLibContext->LibNfcState.next_state)
{
- /*wrong context returned*/
- phOsalNfc_RaiseException(phOsalNfc_e_InternalErr,1);
+ /*If shutdown is called in between allow shutdown to happen*/
+ phLibNfc_Pending_Shutdown();
+ status = NFCSTATUS_SHUTDOWN;
}
else
{
- if(eLibNfcHalStateShutdown == gpphLibContext->LibNfcState.next_state)
+ if(status == NFCSTATUS_SUCCESS)
{
- /*If shutdown is called in between allow shutdown to happen*/
- phLibNfc_Pending_Shutdown();
- status = NFCSTATUS_SHUTDOWN;
- }
- else
- {
- if(status == NFCSTATUS_SUCCESS)
- {
- hSeHandle = pLibContext->sSeContext.hSetemp;
+ hSeHandle = pLibContext->sSeContext.hSetemp;
- if(hSeHandle == sSecuredElementInfo[LIBNFC_SE_UICC_INDEX].hSecureElement)
+ if(hSeHandle == sSecuredElementInfo[LIBNFC_SE_UICC_INDEX].hSecureElement)
+ {
+ if(TRUE==pLibContext->sCardEmulCfg.config.uiccEmuCfg.enableUicc)
{
- if(TRUE==pLibContext->sCardEmulCfg.config.uiccEmuCfg.enableUicc)
- {
- /*If Activation mode was virtual allow external reader to see it*/
- pLibContext->sSeContext.uUiccActivate = TRUE;
- sSecuredElementInfo[LIBNFC_SE_UICC_INDEX].eSE_CurrentState = phLibNfc_SE_Active;
- }
- else
- {
- /*If Activation mode was wired don't allow external reader to see it*/
- pLibContext->sSeContext.uUiccActivate = FALSE;
- sSecuredElementInfo[LIBNFC_SE_UICC_INDEX].eSE_CurrentState =
- phLibNfc_SE_Inactive;
- }
- status = NFCSTATUS_SUCCESS;
- TempState = pLibContext->sSeContext.uUiccActivate;
+ /*If Activation mode was virtual allow external reader to see it*/
+ pLibContext->sSeContext.uUiccActivate = TRUE;
+ sSecuredElementInfo[LIBNFC_SE_UICC_INDEX].eSE_CurrentState = phLibNfc_SE_Active;
}
- else if (hSeHandle==sSecuredElementInfo[LIBNFC_SE_SMARTMX_INDEX].hSecureElement)
+ else
{
- if(TRUE==pLibContext->sCardEmulCfg.config.smartMxCfg.enableEmulation)
- {
- /*If Activation mode was virtual allow external reader to see it*/
- pLibContext->sSeContext.uSmxActivate = TRUE;
- sSecuredElementInfo[LIBNFC_SE_SMARTMX_INDEX].eSE_CurrentState =
- phLibNfc_SE_Active;
- }
- else
- {
- /*If Activation mode was wired don't allow external reader to see it*/
- pLibContext->sSeContext.uSmxActivate = FALSE;
- sSecuredElementInfo[LIBNFC_SE_SMARTMX_INDEX].eSE_CurrentState=
- phLibNfc_SE_Inactive;
- }
- status = NFCSTATUS_SUCCESS;
- TempState = pLibContext->sSeContext.uSmxActivate;
+ /*If Activation mode was wired don't allow external reader to see it*/
+ pLibContext->sSeContext.uUiccActivate = FALSE;
+ sSecuredElementInfo[LIBNFC_SE_UICC_INDEX].eSE_CurrentState =
+ phLibNfc_SE_Inactive;
+ }
+ status = NFCSTATUS_SUCCESS;
+ TempState = pLibContext->sSeContext.uUiccActivate;
+ }
+ else if (hSeHandle==sSecuredElementInfo[LIBNFC_SE_SMARTMX_INDEX].hSecureElement)
+ {
+ if(TRUE==pLibContext->sCardEmulCfg.config.smartMxCfg.enableEmulation)
+ {
+ /*If Activation mode was virtual allow external reader to see it*/
+ pLibContext->sSeContext.uSmxActivate = TRUE;
+ sSecuredElementInfo[LIBNFC_SE_SMARTMX_INDEX].eSE_CurrentState =
+ phLibNfc_SE_Active;
}
else
{
- status = NFCSTATUS_FAILED;
+ /*If Activation mode was wired don't allow external reader to see it*/
+ pLibContext->sSeContext.uSmxActivate = FALSE;
+ sSecuredElementInfo[LIBNFC_SE_SMARTMX_INDEX].eSE_CurrentState=
+ phLibNfc_SE_Inactive;
}
+ status = NFCSTATUS_SUCCESS;
+ TempState = pLibContext->sSeContext.uSmxActivate;
}
else
{
status = NFCSTATUS_FAILED;
}
- pLibContext->status.GenCb_pending_status = FALSE;
}
-
+ else
+ {
+ status = NFCSTATUS_FAILED;
+ }
+ pLibContext->status.GenCb_pending_status = FALSE;
}
+
pUpperLayerCb = pLibContext->sSeContext.sSeCallabackInfo.pSEsetModeCb;
pUpperContext = pLibContext->sSeContext.sSeCallabackInfo.pSEsetModeCtxt;
pLibContext->sSeContext.sSeCallabackInfo.pSEsetModeCb = NULL;