summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatt Derksen <mderkse1@us.ibm.com>2019-03-29 12:10:48 -0500
committerNicholas E. Bofferding <bofferdn@us.ibm.com>2019-04-15 09:13:21 -0500
commitecfbca46ab3fba9f66ce242e3c226c6c6e18ce26 (patch)
tree4fea424075494eada8dc7c18a8b16e12eca34da0
parentdeec9656ec007cde650eabfdd8c90eb2da8518f5 (diff)
downloadtalos-hostboot-ecfbca46ab3fba9f66ce242e3c226c6c6e18ce26.tar.gz
talos-hostboot-ecfbca46ab3fba9f66ce242e3c226c6c6e18ce26.zip
Make sure memory is cleaned up in errlud_i2c.C
This small update is based on review comments to a previous fix of runtime i2c crashing issue. Previous Change: I6c912e71b22da80b166e13dc66bdf0e5a51abfbb Change-Id: If9c33773777943a67f9a5e00d48f0647b45c8406 Reviewed-on: http://rchgit01.rchland.ibm.com/gerrit1/75235 Tested-by: Jenkins Server <pfd-jenkins+hostboot@us.ibm.com> Reviewed-by: Nicholas E. Bofferding <bofferdn@us.ibm.com> Tested-by: FSP CI Jenkins <fsp-CI-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> Reviewed-by: Christian R. Geddes <crgeddes@us.ibm.com> Reviewed-by: Daniel M. Crowell <dcrowell@us.ibm.com>
-rw-r--r--src/usr/i2c/errlud_i2c.C17
1 files changed, 9 insertions, 8 deletions
diff --git a/src/usr/i2c/errlud_i2c.C b/src/usr/i2c/errlud_i2c.C
index 980d5274f..772ff9d9c 100644
--- a/src/usr/i2c/errlud_i2c.C
+++ b/src/usr/i2c/errlud_i2c.C
@@ -76,7 +76,10 @@ UdI2CParms::UdI2CParms( uint8_t i_opType,
if (i_args.i2cMuxPath)
{
l_muxPath = i_args.i2cMuxPath->toString();
- l_muxPathSize = strlen(l_muxPath);
+ if (l_muxPath != nullptr)
+ {
+ l_muxPathSize = strlen(l_muxPath);
+ }
}
char * l_pBuf = reinterpret_cast<char *>(
reallocUsrBuf(sizeof(uint8_t)*2
@@ -173,16 +176,14 @@ UdI2CParms::UdI2CParms( uint8_t i_opType,
if (l_muxPathSize > 0)
{
- memcpy(l_pBuf, l_muxPath, strlen(l_muxPath));
- l_pBuf += strlen(l_muxPath);
-
- // done with muxPath so free it here
- free(l_muxPath);
- l_muxPath = nullptr;
- l_muxPathSize = 0;
+ memcpy(l_pBuf, l_muxPath, l_muxPathSize);
+ l_pBuf += l_muxPathSize;
}
*l_pBuf = '\0'; // add a terminator for ease of parsing
++l_pBuf;
+
+ free(l_muxPath);
+ l_muxPath = nullptr;
}
//------------------------------------------------------------------------------
OpenPOWER on IntegriCloud