|
|
5845dfa |
From 84eeef108d36c7aa725e6b8098960937c5d1b38e Mon Sep 17 00:00:00 2001
|
|
|
5845dfa |
From: Scott Tsai <scottt.tw@gmail.com>
|
|
|
5845dfa |
Date: Fri, 16 Dec 2011 05:56:39 +0800
|
|
|
5845dfa |
Subject: [PATCH] svf: guard against chain->cable being NULL
|
|
|
5845dfa |
|
|
|
5845dfa |
While processing:
|
|
|
5845dfa |
cable ft2232 vid=0x0403 pid=0x6011
|
|
|
5845dfa |
bsdl path .
|
|
|
5845dfa |
detect
|
|
|
5845dfa |
svf ./orpsoc_top.svf stop progress
|
|
|
5845dfa |
quit
|
|
|
5845dfa |
|
|
|
5845dfa |
If the specified cable isn't present, jtag would SEGFAULT with this backtrace:
|
|
|
5845dfa |
#0 urj_tap_cable_get_frequency (cable=0x0) at cable.c:529
|
|
|
5845dfa |
#1 0x00007fefd4f4803a in urj_svf_run (chain=0x20562a0, SVF_FILE=0x20567b0, stop_on_mismatch=1, ref_freq=0) at svf.c:1117
|
|
|
5845dfa |
#2 0x00007fefd4f40681 in cmd_svf_run (chain=0x20562a0, params=0x20565a0) at cmd_svf.c:83
|
|
|
5845dfa |
#3 0x00007fefd4f3e9ad in urj_cmd_run (chain=0x20562a0, params=0x20565a0) at cmd_cmd.c:276
|
|
|
5845dfa |
#4 0x00007fefd4f4438d in urj_parse_line (chain=0x20562a0, line=0x2056520 "svf ./orpsoc_top.svf stop progress") at parse.c:165
|
|
|
5845dfa |
#5 0x00007fefd4f44447 in urj_parse_stream (chain=0x20562a0, f=0x20562e0) at parse.c:207
|
|
|
5845dfa |
#6 0x00007fefd4f4456b in urj_parse_file (chain=0x20562a0, filename=0x7fff90576b92 "./program_fpga.jtag") at parse.c:235
|
|
|
5845dfa |
#7 0x00000000004016c1 in main (argc=2, argv=<optimized out>) at jtag.c:486
|
|
|
5845dfa |
|
|
|
5845dfa |
This patch changes urj_svf_run to guard against chain->cable being NULL.
|
|
|
5845dfa |
---
|
|
|
5845dfa |
urjtag/src/svf/svf.c | 7 ++++++-
|
|
|
5845dfa |
1 files changed, 6 insertions(+), 1 deletions(-)
|
|
|
5845dfa |
|
|
|
5845dfa |
diff --git a/urjtag/src/svf/svf.c b/urjtag/src/svf/svf.c
|
|
|
5845dfa |
index 9552a6d..2282c77 100644
|
|
|
5845dfa |
--- a/urjtag/src/svf/svf.c
|
|
|
5845dfa |
+++ b/urjtag/src/svf/svf.c
|
|
|
5845dfa |
@@ -1114,7 +1114,12 @@ urj_svf_run (urj_chain_t *chain, FILE *SVF_FILE, int stop_on_mismatch,
|
|
|
5845dfa |
urj_svf_parser_priv_t priv;
|
|
|
5845dfa |
int c = ~EOF;
|
|
|
5845dfa |
int num_lines;
|
|
|
5845dfa |
- uint32_t old_frequency = urj_tap_cable_get_frequency (chain->cable);
|
|
|
5845dfa |
+ uint32_t old_frequency;
|
|
|
5845dfa |
+
|
|
|
5845dfa |
+ if (chain == NULL || chain->cable == NULL)
|
|
|
5845dfa |
+ return URJ_STATUS_FAIL;
|
|
|
5845dfa |
+
|
|
|
5845dfa |
+ old_frequency = urj_tap_cable_get_frequency (chain->cable);
|
|
|
5845dfa |
|
|
|
5845dfa |
/* get number of lines in svf file so we can give user some feedback on long
|
|
|
5845dfa |
files or slow cables */
|
|
|
5845dfa |
--
|
|
|
5845dfa |
1.7.7.5
|
|
|
5845dfa |
|