diff options
author | Brian Horton <brianh@linux.ibm.com> | 2013-03-28 07:18:53 -0500 |
---|---|---|
committer | A. Patrick Williams III <iawillia@us.ibm.com> | 2013-04-08 11:12:57 -0500 |
commit | 7ff6891151bbcf3a86feafcc3c59fdf4b82ce703 (patch) | |
tree | 625708ead1ab8da4193ea2cf0dd9871410aa016e | |
parent | 0b54ea77e9ae3ba7195d118a1a0ed5ae39566226 (diff) | |
download | talos-hostboot-7ff6891151bbcf3a86feafcc3c59fdf4b82ce703.tar.gz talos-hostboot-7ff6891151bbcf3a86feafcc3c59fdf4b82ce703.zip |
check for NULL after return from translateAddr
in response to crash on FSP; translateAddr() can return NULL
if the address is invalid, so all callers need to handle this
case.
Change-Id: Ic172fcc48c026bfb0394c0f33079c1a04a180694
RTC: 67793
Reviewed-on: http://gfw160.austin.ibm.com:8080/gerrit/3779
Tested-by: Jenkins Server
Reviewed-by: Nicholas E. Bofferding <bofferdn@us.ibm.com>
Reviewed-by: A. Patrick Williams III <iawillia@us.ibm.com>
-rw-r--r-- | src/usr/targeting/common/target.C | 56 | ||||
-rw-r--r-- | src/usr/targeting/common/targetservice.C | 4 |
2 files changed, 35 insertions, 25 deletions
diff --git a/src/usr/targeting/common/target.C b/src/usr/targeting/common/target.C index 6e92e53fc..b91cc98fe 100644 --- a/src/usr/targeting/common/target.C +++ b/src/usr/targeting/common/target.C @@ -135,30 +135,36 @@ void Target::_getAttrPtr( TARG_GET_SINGLETON(TARGETING::theAttrRP).translateAddr(ppAttrAddr)); } - // Iterate through all the target's attribute IDs - for (uint32_t i = 0; i < iv_attrs; ++i) - { - // Point to the ith attribute ID. If it matches the requested attribute - // ID, - // look up the attribute's address - if (*(pAttrId+i) == i_attr) + if ((pAttrId != NULL) && (ppAttrAddr != NULL)) + { // only check for the attribute if we got a valid address from + // the translateAddr function + + // Iterate through all the target's attribute IDs + for (uint32_t i = 0; i < iv_attrs; ++i) { - // Locate the corresponding attribute address - l_pAttr = TARG_TO_PLAT_PTR(*(ppAttrAddr+i)); - - // Only translate addresses on platforms where addresses are 4 bytes - // wide (FSP). The compiler should perform dead code elimination of - // this path on platforms with 8 byte wide addresses (Hostboot), - // since the "if" check can be statically computed at compile time. - if(TARG_ADDR_TRANSLATION_REQUIRED) + // Point to the ith attribute ID. If it matches the requested + // attribute ID, + // look up the attribute's address + if (*(pAttrId+i) == i_attr) { - l_pAttr = - TARG_GET_SINGLETON(TARGETING::theAttrRP).translateAddr( - l_pAttr); + // Locate the corresponding attribute address + l_pAttr = TARG_TO_PLAT_PTR(*(ppAttrAddr+i)); + + // Only translate addresses on platforms where addresses are + // 4 byte wide (FSP). The compiler should perform dead code + // elimination this path on platforms with 8 byte wide + // addresses (Hostboot), since the "if" check can be statically + // computed at compile time. + if(TARG_ADDR_TRANSLATION_REQUIRED) + { + l_pAttr = + TARG_GET_SINGLETON(TARGETING::theAttrRP).translateAddr( + l_pAttr); + } + + break; } - - break; - } + } // for } o_pAttr = l_pAttr; @@ -230,12 +236,12 @@ uint8_t * Target::targetFFDC( uint32_t & o_size ) const AttributeTraits<ATTR_CLASS>::Type attrClass = getAttr<ATTR_CLASS>(); AttributeTraits<ATTR_TYPE>::Type attrType = getAttr<ATTR_TYPE>(); AttributeTraits<ATTR_MODEL>::Type attrModel = getAttr<ATTR_MODEL>(); - uint32_t headerSize = sizeof(attrHuid) + - sizeof(attrClass) + sizeof(attrType) + + uint32_t headerSize = sizeof(attrHuid) + + sizeof(attrClass) + sizeof(attrType) + sizeof(attrModel); uint32_t attrEnum = ATTR_NA; - + uint8_t pathPhysSize = 0; AttributeTraits<ATTR_PHYS_PATH>::Type pathPhys; if( tryGetAttr<ATTR_PHYS_PATH>(pathPhys) ) { @@ -257,7 +263,7 @@ uint8_t * Target::targetFFDC( uint32_t & o_size ) const // to compensate for the size of that attribute type, when applicable pFFDC = static_cast<uint8_t*>( malloc( headerSize - + pathPhysSize + + pathPhysSize + sizeof(attrEnum) + pathAffSize + sizeof(attrEnum))); diff --git a/src/usr/targeting/common/targetservice.C b/src/usr/targeting/common/targetservice.C index f476e6fee..399e4e1d8 100644 --- a/src/usr/targeting/common/targetservice.C +++ b/src/usr/targeting/common/targetservice.C @@ -658,6 +658,10 @@ uint32_t TargetService::_maxTargets() pNumTargets)); } + TARG_ASSERT(pNumTargets, TARG_ERR_LOC + "FATAL: Could not determine location of targets after " + "address translation"); + iv_maxTargets = *pNumTargets; TARG_INF("Max targets = %d",iv_maxTargets); |