From 5ecaf30219d8a846f2747d4d67503c21c6e13333 Mon Sep 17 00:00:00 2001 From: Ali Saidi Date: Thu, 10 May 2012 18:04:27 -0500 Subject: [PATCH] gem5: fix a number of use after free issues --- src/cpu/checker/cpu.cc | 3 ++- src/sim/eventq.hh | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/cpu/checker/cpu.cc b/src/cpu/checker/cpu.cc index 901c3900f..73205dc35 100644 --- a/src/cpu/checker/cpu.cc +++ b/src/cpu/checker/cpu.cc @@ -264,13 +264,14 @@ CheckerCPU::writeMem(uint8_t *data, unsigned size, * enabled. This is left as future work for the Checker: LSQ snooping * and memory validation after stores have committed. */ + bool was_prefetch = memReq->isPrefetch(); delete memReq; //If we don't need to access a second cache line, stop now. if (fault != NoFault || secondAddr <= addr) { - if (fault != NoFault && memReq->isPrefetch()) { + if (fault != NoFault && was_prefetch) { fault = NoFault; } break; diff --git a/src/sim/eventq.hh b/src/sim/eventq.hh index c859823c8..e7d088e80 100644 --- a/src/sim/eventq.hh +++ b/src/sim/eventq.hh @@ -516,11 +516,11 @@ EventQueue::deschedule(Event *event) event->flags.clear(Event::Squashed); event->flags.clear(Event::Scheduled); - if (event->flags.isSet(Event::AutoDelete)) - delete event; - if (DTRACE(Event)) event->trace("descheduled"); + + if (event->flags.isSet(Event::AutoDelete)) + delete event; } inline void -- 2.30.2