From 40878611d8bbd9dfec0174fbad0400d6bfa1522a Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Sun, 28 Nov 2010 18:04:41 +0000 Subject: [PATCH] fix segfault in ejtag bus when EJADDRESS or EJDATA are missing git-svn-id: https://urjtag.svn.sourceforge.net/svnroot/urjtag/trunk@1868 b68d4a1b-bc3d-0410-92ed-d4ac073336b7 --- urjtag/ChangeLog | 5 +++++ urjtag/src/bus/ejtag.c | 9 +++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/urjtag/ChangeLog b/urjtag/ChangeLog index 03e27371..eaa88b4d 100644 --- a/urjtag/ChangeLog +++ b/urjtag/ChangeLog @@ -1,3 +1,8 @@ +2010-11-28 Mike Frysinger + + * src/bus/ejtag.c (ejtag_bus_init): Punt unused EJALL register lookup. + Make sure EJADDRESS and EJDATA registers exist before we use them. + 2010-11-19 Mike Frysinger * acinclude.m4 (LT_INIT): Fix typo in fallback macro. diff --git a/urjtag/src/bus/ejtag.c b/urjtag/src/bus/ejtag.c index 06bce05b..1c36c5bc 100644 --- a/urjtag/src/bus/ejtag.c +++ b/urjtag/src/bus/ejtag.c @@ -269,7 +269,7 @@ ejtag_run_pracc (urj_bus_t *bus, const uint32_t *code, unsigned int len) static int ejtag_bus_init (urj_bus_t *bus) { - urj_data_register_t *ejctrl, *ejimpl, *ejaddr, *ejdata, *ejall; + urj_data_register_t *ejctrl, *ejimpl, *ejaddr, *ejdata; uint32_t code[4] = { 0x3c04ff20, // lui $4,0xff20 0x349f0200, // ori $31,$4,0x0200 @@ -290,7 +290,6 @@ ejtag_bus_init (urj_bus_t *bus) ejimpl = urj_part_find_data_register (bus->part, "EJIMPCODE"); ejaddr = urj_part_find_data_register (bus->part, "EJADDRESS"); ejdata = urj_part_find_data_register (bus->part, "EJDATA"); - ejall = urj_part_find_data_register (bus->part, "EJALL"); if (!(ejctrl && ejimpl)) { urj_error_set (URJ_ERROR_NOTFOUND, @@ -353,6 +352,12 @@ ejtag_bus_init (urj_bus_t *bus) // if (EJTAG_VER == EJTAG_20) { + if (!(ejaddr && ejdata)) + { + urj_error_set (URJ_ERROR_NOTFOUND, + _("EJADDRESS or EJDATA register not found")); + return URJ_STATUS_FAIL; + } // Try enabling memory write on EJTAG_20 (BCM6348) // Badly Copied from HairyDairyMaid V4.8 //ejtag_dma_write(0xff300000, (ejtag_dma_read(0xff300000) & ~(1<<2)) );