Skip to content

Commit

Permalink
Fix ThreadPool Memory Corruption
Browse files Browse the repository at this point in the history
One of the functions that ends up being called by threads spun by
ThreadPool has a potential memory corruption where a vector of data
structures can be searched while it's being populated by two different
threads. This commit changes the positions of mutex lock and ulock
calls in the vicinity to protect the population and search of the vector.

Change-Id: Ic1a5eb8928c1133ee2a99e2d9c04607be3c41b15
CQ: SW476649
Reviewed-on: http://rchgit01.rchland.ibm.com/gerrit1/84561
Tested-by: Jenkins Server <pfd-jenkins+hostboot@us.ibm.com>
Tested-by: Jenkins OP Build CI <op-jenkins+hostboot@us.ibm.com>
Tested-by: Jenkins OP HW <op-hw-jenkins+hostboot@us.ibm.com>
Tested-by: FSP CI Jenkins <fsp-CI-jenkins+hostboot@us.ibm.com>
Reviewed-by: Christian R Geddes <crgeddes@us.ibm.com>
Reviewed-by: Nicholas E Bofferding <bofferdn@us.ibm.com>
Reviewed-by: Daniel M Crowell <dcrowell@us.ibm.com>
  • Loading branch information
Ilya Smirnov authored and dcrowell77 committed Oct 2, 2019
1 parent adc61f1 commit 0e56212
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/usr/fapi2/attribute_service.C
Expand Up @@ -2081,6 +2081,7 @@ ReturnCode platGetDQAttrISDIMM(
}
else
{
mutex_lock(&l_C4DQmutex);
auto l_huid = TARGETING::get_huid(l_pTarget);
auto l_iterator = std::find ( l_cachedC4DQValues.begin(),
l_cachedC4DQValues.end(),
Expand All @@ -2093,14 +2094,13 @@ ReturnCode platGetDQAttrISDIMM(
l_kvPair.huid = l_huid;
rc = getDQAttrISDIMM(l_fapiTarget, l_kvPair.value);
memcpy(o_vpdIsDimmTOC4DQVal, l_kvPair.value, sizeof(ATTR_CEN_VPD_ISDIMMTOC4DQ_Type));
mutex_lock(&l_C4DQmutex);
l_cachedC4DQValues.push_back(l_kvPair);
mutex_unlock(&l_C4DQmutex);
}
else
{
memcpy(o_vpdIsDimmTOC4DQVal, (*l_iterator).value, sizeof(ATTR_CEN_VPD_ISDIMMTOC4DQ_Type));
}
mutex_unlock(&l_C4DQmutex);
}

return rc;
Expand Down Expand Up @@ -2132,6 +2132,7 @@ ReturnCode platGetDQSAttrISDIMM(
}
else
{
mutex_lock(&l_C4DQSmutex);
auto l_huid = TARGETING::get_huid(l_pTarget);
auto l_iterator = std::find ( l_cachedC4DQSValues.begin(),
l_cachedC4DQSValues.end(),
Expand All @@ -2145,14 +2146,13 @@ ReturnCode platGetDQSAttrISDIMM(
l_kvPair.huid = l_huid;
rc = getDQSAttrISDIMM(l_fapiTarget, l_kvPair.value);
memcpy(o_vpdIsDimmTOC4DQSVal, l_kvPair.value, sizeof(ATTR_CEN_VPD_ISDIMMTOC4DQS_Type));
mutex_lock(&l_C4DQSmutex);
l_cachedC4DQSValues.push_back(l_kvPair);
mutex_unlock(&l_C4DQSmutex);
}
else
{
memcpy(o_vpdIsDimmTOC4DQSVal, (*l_iterator).value, sizeof(ATTR_CEN_VPD_ISDIMMTOC4DQS_Type));
}
mutex_unlock(&l_C4DQSmutex);
}

return rc;
Expand Down

0 comments on commit 0e56212

Please sign in to comment.