From d2fd055febb7951474bffd527cc88e189a866ee3 Mon Sep 17 00:00:00 2001 From: Caleb Palmer Date: Fri, 2 Mar 2018 15:06:13 -0600 Subject: Free mem and fix dimm trgt in bad dq accessors Change-Id: I8db862122b9bab7eae2e75a4188c863704e9fdcd CQ: SW419983 Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/54996 Tested-by: Jenkins Server Tested-by: Jenkins OP Build CI Tested-by: Jenkins OP HW Tested-by: FSP CI Jenkins Reviewed-by: Benjamin J. Weisenbeck Reviewed-by: Brian J. Stegmiller Reviewed-by: Zane C. Shelley --- src/usr/fapi2/attribute_service.C | 33 ++++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-) (limited to 'src/usr/fapi2/attribute_service.C') diff --git a/src/usr/fapi2/attribute_service.C b/src/usr/fapi2/attribute_service.C index 1089f97e4..dfcaff74a 100644 --- a/src/usr/fapi2/attribute_service.C +++ b/src/usr/fapi2/attribute_service.C @@ -695,11 +695,10 @@ errlHndl_t __dimmUpdateDqBitmapEccByte( const uint8_t ECC_DQ_BYTE_NUMBER_INDEX = 8; const uint8_t ENUM_ATTR_SPD_MODULE_MEMORY_BUS_WIDTH_WE8 = 0x08; size_t MEM_BUS_WIDTH_SIZE = 0x01; + uint8_t *l_eccBits = static_cast(malloc(MEM_BUS_WIDTH_SIZE)); do { - uint8_t *l_eccBits = static_cast(malloc(MEM_BUS_WIDTH_SIZE)); - l_errl = deviceRead( i_dimm, l_eccBits, MEM_BUS_WIDTH_SIZE, @@ -729,6 +728,12 @@ errlHndl_t __dimmUpdateDqBitmapEccByte( } }while(0); + if ( l_eccBits != nullptr ) + { + free( l_eccBits ); + l_eccBits = nullptr; + } + return l_errl; } @@ -1222,6 +1227,9 @@ ReturnCode fapiAttrGetBadDqBitmap( errlHndl_t l_errl = nullptr; TARGETING::TargetHandle_t l_dimmTarget = nullptr; + uint8_t * l_badDqData = + static_cast( malloc(DIMM_BAD_DQ_SIZE_BYTES) ); + do { l_errl = getTargetingTarget( i_dimmFapiTarget, l_dimmTarget ); @@ -1245,9 +1253,6 @@ ReturnCode fapiAttrGetBadDqBitmap( break; } - uint8_t * l_badDqData = - static_cast( malloc(DIMM_BAD_DQ_SIZE_BYTES) ); - l_errl = deviceRead(l_dimmTarget, l_badDqData, DIMM_BAD_DQ_SIZE_BYTES, DEVICE_SPD_ADDRESS(SPD::DIMM_BAD_DQ_DATA)); @@ -1363,6 +1368,12 @@ ReturnCode fapiAttrGetBadDqBitmap( }while(0); + if ( l_badDqData != nullptr ) + { + free( l_badDqData ); + l_badDqData = nullptr; + } + return l_rc; } @@ -1376,7 +1387,8 @@ ReturnCode fapiAttrSetBadDqBitmap( fapi2::ReturnCode l_rc; errlHndl_t l_errl = nullptr; TARGETING::TargetHandle_t l_dimmTarget = nullptr; - + uint8_t * l_badDqData = + static_cast( malloc(DIMM_BAD_DQ_SIZE_BYTES) ); do { l_errl = getTargetingTarget(i_dimmFapiTarget, l_dimmTarget); @@ -1507,9 +1519,6 @@ ReturnCode fapiAttrSetBadDqBitmap( // We need to make sure the rest of the data in VPD beyond the bad dq // bitmap is unchanged. - uint8_t * l_badDqData = - static_cast( malloc(DIMM_BAD_DQ_SIZE_BYTES) ); - l_errl = deviceRead(l_dimmTarget, l_badDqData, DIMM_BAD_DQ_SIZE_BYTES, DEVICE_SPD_ADDRESS(SPD::DIMM_BAD_DQ_DATA)); @@ -1560,6 +1569,12 @@ ReturnCode fapiAttrSetBadDqBitmap( }while(0); + if ( l_badDqData != nullptr ) + { + free( l_badDqData ); + l_badDqData = nullptr; + } + return l_rc; } -- cgit v1.2.1