gem5: fix a number of use after free issues
authorAli Saidi <Ali.Saidi@ARM.com>
Thu, 10 May 2012 23:04:27 +0000 (18:04 -0500)
committerAli Saidi <Ali.Saidi@ARM.com>
Thu, 10 May 2012 23:04:27 +0000 (18:04 -0500)
src/cpu/checker/cpu.cc
src/sim/eventq.hh

index 901c3900f18ad4c693202d0085871a861c130502..73205dc351de56980a452872100ce5ad5968e8dc 100644 (file)
@@ -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;
index c859823c8ed2943eaaba7365f60f340ad09c5363..e7d088e809f0c50b1bd7ae7a456d539f6a0ce749 100644 (file)
@@ -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