diff options
author | Gabe Black <gabeblack@google.com> | 2019-03-01 13:57:35 -0800 |
---|---|---|
committer | Gabe Black <gabeblack@google.com> | 2019-03-01 23:41:51 +0000 |
commit | 050545fc180fc9bdb27d9c0813f9d0043a89e7f7 (patch) | |
tree | 75d9c2b4053a96f0daa0dc51511b6c85f39570a8 /util | |
parent | 524b673421ca7802011d6d50e37b716126f3d81b (diff) | |
download | gem5-050545fc180fc9bdb27d9c0813f9d0043a89e7f7.tar.xz |
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 <jason@lowepower.com>
Maintainer: Gabe Black <gabeblack@google.com>
Diffstat (limited to 'util')
-rw-r--r-- | util/tlm/src/sc_master_port.cc | 2 |
1 files changed, 1 insertions, 1 deletions
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); |