changeset ac3236a0873b in /z/repo/gem5
details: http://repo.gem5.org/gem5?cmd=changeset;node=ac3236a0873b
description:
        dev: Fix undefined behaviuor in i8254xGBe

        This patch fixes a rather unfortunate oversight where the annotation
        pointer was used even though it is null. Somehow the code still works,
        but UBSan is rather unhappy. The use is now guarded, and the variable
        is initialised in the constructor (as well as init()).

diffstat:

 src/dev/i8254xGBe.cc |   4 ++--
 src/dev/i8254xGBe.hh |  23 +++++++++++++++--------
 2 files changed, 17 insertions(+), 10 deletions(-)

diffs (71 lines):

diff -r aaa0f985da8e -r ac3236a0873b src/dev/i8254xGBe.cc
--- a/src/dev/i8254xGBe.cc      Mon Feb 16 03:34:18 2015 -0500
+++ b/src/dev/i8254xGBe.cc      Mon Feb 16 03:34:35 2015 -0500
@@ -58,7 +58,7 @@
 using namespace Net;
 
 IGbE::IGbE(const Params *p)
-    : EtherDevice(p), etherInt(NULL),  drainManager(NULL),
+    : EtherDevice(p), etherInt(NULL), cpa(NULL), drainManager(NULL),
       rxFifo(p->rx_fifo_size), txFifo(p->tx_fifo_size), rxTick(false),
       txTick(false), txFifoTick(false), rxDmaPacket(false), pktOffset(0),
       fetchDelay(p->fetch_delay), wbDelay(p->wb_delay), 
@@ -2390,7 +2390,7 @@
 
     anPq("TXQ", "TX FIFO Q");
     if (etherInt->sendPacket(txFifo.front())) {
-        cpa->hwQ(CPA::FL_NONE, sys, macAddr, "TXQ", "WireQ", 0);
+        anQ("TXQ", "WireQ");
         if (DTRACE(EthernetSM)) {
             IpPtr ip(txFifo.front());
             if (ip)
diff -r aaa0f985da8e -r ac3236a0873b src/dev/i8254xGBe.hh
--- a/src/dev/i8254xGBe.hh      Mon Feb 16 03:34:18 2015 -0500
+++ b/src/dev/i8254xGBe.hh      Mon Feb 16 03:34:35 2015 -0500
@@ -182,31 +182,38 @@
     void checkDrain();
 
     void anBegin(std::string sm, std::string st, int flags = CPA::FL_NONE) {
-        cpa->hwBegin((CPA::flags)flags, sys, macAddr, sm, st);
+        if (cpa)
+            cpa->hwBegin((CPA::flags)flags, sys, macAddr, sm, st);
     }
 
-    void anQ(std::string sm, std::string q) { 
-        cpa->hwQ(CPA::FL_NONE, sys, macAddr, sm, q, macAddr);
+    void anQ(std::string sm, std::string q) {
+        if (cpa)
+            cpa->hwQ(CPA::FL_NONE, sys, macAddr, sm, q, macAddr);
     }
 
     void anDq(std::string sm, std::string q) {
-        cpa->hwDq(CPA::FL_NONE, sys, macAddr, sm, q, macAddr);
+        if (cpa)
+            cpa->hwDq(CPA::FL_NONE, sys, macAddr, sm, q, macAddr);
     }
 
     void anPq(std::string sm, std::string q, int num = 1) {
-        cpa->hwPq(CPA::FL_NONE, sys, macAddr, sm, q, macAddr, NULL, num);
+        if (cpa)
+            cpa->hwPq(CPA::FL_NONE, sys, macAddr, sm, q, macAddr, NULL, num);
     }
 
     void anRq(std::string sm, std::string q, int num = 1) {
-        cpa->hwRq(CPA::FL_NONE, sys, macAddr, sm, q, macAddr, NULL, num);
+        if (cpa)
+            cpa->hwRq(CPA::FL_NONE, sys, macAddr, sm, q, macAddr, NULL, num);
     }
 
     void anWe(std::string sm, std::string q) {
-        cpa->hwWe(CPA::FL_NONE, sys, macAddr, sm, q, macAddr);
+        if (cpa)
+            cpa->hwWe(CPA::FL_NONE, sys, macAddr, sm, q, macAddr);
     }
 
     void anWf(std::string sm, std::string q) {
-        cpa->hwWf(CPA::FL_NONE, sys, macAddr, sm, q, macAddr);
+        if (cpa)
+            cpa->hwWf(CPA::FL_NONE, sys, macAddr, sm, q, macAddr);
     }
 
 
_______________________________________________
gem5-dev mailing list
[email protected]
http://m5sim.org/mailman/listinfo/gem5-dev

Reply via email to