From 0fed64a6a47a62a94a53c5f41ac89b34a2fd6786 Mon Sep 17 00:00:00 2001 From: Ali Saidi Date: Thu, 2 Mar 2006 17:49:12 -0500 Subject: [PATCH] Fix fault handling, dereferincing a null pointer is bad. --HG-- extra : convert_revision : a4f658bfd39b7f1d219ad8929b8f45457f49299f --- cpu/simple/cpu.cc | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/cpu/simple/cpu.cc b/cpu/simple/cpu.cc index d826c589e..ca5d54694 100644 --- a/cpu/simple/cpu.cc +++ b/cpu/simple/cpu.cc @@ -347,12 +347,12 @@ SimpleCPU::copySrcTranslate(Addr src) // translate to physical address Fault fault = xc->translateDataReadReq(memReq); - assert(!fault->isAlignmentFault()); - if (fault == NoFault) { xc->copySrcAddr = src; xc->copySrcPhysAddr = memReq->paddr + offset; } else { + assert(!fault->isAlignmentFault()); + xc->copySrcAddr = 0; xc->copySrcPhysAddr = 0; } @@ -382,8 +382,6 @@ SimpleCPU::copy(Addr dest) // translate to physical address Fault fault = xc->translateDataWriteReq(memReq); - assert(!fault->isAlignmentFault()); - if (fault == NoFault) { Addr dest_addr = memReq->paddr + offset; // Need to read straight from memory since we have more than 8 bytes. @@ -402,6 +400,9 @@ SimpleCPU::copy(Addr dest) dcacheInterface->access(memReq); } } + else + assert(!fault->isAlignmentFault()); + return fault; } -- 2.30.2