From: Gabe Black Date: Fri, 1 Mar 2019 21:57:35 +0000 (-0800) Subject: util, tlm: Fix a memory error in the SCMasterPort class. X-Git-Tag: v19.0.0.0~1075 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=050545fc180fc9bdb27d9c0813f9d0043a89e7f7;p=gem5.git util, tlm: Fix a memory error in the SCMasterPort class. In the b_transport method of the SCMasterPort class, there is a check which determines whether the packet being sent to gem5 should be deleted once the call to sendAtomic returns. This was deleting the packet if extension was *not* nullptr. This check should delete the packet if the extension *is* nullptr. The reasoning is that the extension will equal nullptr if there was no gem5 packet in an extension and a new one needed to be allocated. If there was an extension, ie if extension is not nullptr, then that's where the packet came from which therefore doesn't belong to us. In that case, we need to leave it alone and let its owner clean it up. With the check reversed, this method will either leak allocated packets it should delete, or delete packets it shouldn't that someone else will likely try to use later. Change-Id: I61578d910be6e5085b9fc0ddaa82468b1ac68578 Reviewed-on: https://gem5-review.googlesource.com/c/16949 Reviewed-by: Jason Lowe-Power Maintainer: Gabe Black --- diff --git a/util/tlm/src/sc_master_port.cc b/util/tlm/src/sc_master_port.cc index ab2bc4aba..864e16956 100644 --- a/util/tlm/src/sc_master_port.cc +++ b/util/tlm/src/sc_master_port.cc @@ -284,7 +284,7 @@ SCMasterPort::b_transport(tlm::tlm_generic_payload& trans, // update time t += delay; - if (extension != nullptr) + if (extension == nullptr) destroyPacket(pkt); trans.set_response_status(tlm::TLM_OK_RESPONSE);