Angel Pons has uploaded this change for review.

View Change

Fix segfault when running `flashrom -L`

The raiden_debug programmer is of type USB. However, it does not set the
field `devs.dev`, which will result in a segfault when trying to print
the devices of the non-existing table.

FIx that by replacing `devs.note` with `devs.dev` and adding an empty
device table. Since Device IDs are not used to match programmers,
nothing could be added to the table.

TEST=Running `flashrom -L` no longer segfaults and returns normally.

Change-Id: Ie4171a11384c34abb102d1aadf86aa1b8829fc04
Signed-off-by: Angel Pons <th3fanbus@gmail.com>
---
M flashrom.c
M programmer.h
M raiden_debug_spi.c
3 files changed, 7 insertions(+), 1 deletion(-)

git pull ssh://review.coreboot.org:29418/flashrom refs/changes/26/39826/1
diff --git a/flashrom.c b/flashrom.c
index e541b68..081b705 100644
--- a/flashrom.c
+++ b/flashrom.c
@@ -137,7 +137,7 @@
{
.name = "raiden_debug",
.type = USB,
- .devs.note = "All programmer devices speaking the raiden protocol\n",
+ .devs.dev = devs_raiden,
.init = raiden_debug_spi_init,
.map_flash_region = fallback_map,
.unmap_flash_region = fallback_unmap,
diff --git a/programmer.h b/programmer.h
index 08500c6..9a41be1 100644
--- a/programmer.h
+++ b/programmer.h
@@ -407,6 +407,7 @@
/* raiden_debug_spi.c */
#if CONFIG_RAIDEN == 1
int raiden_debug_spi_init(void);
+extern const struct dev_entry devs_raiden[];
#endif

/* drkaiser.c */
diff --git a/raiden_debug_spi.c b/raiden_debug_spi.c
index 6914455..173e355 100644
--- a/raiden_debug_spi.c
+++ b/raiden_debug_spi.c
@@ -116,6 +116,11 @@
#include <string.h>
#include <unistd.h>

+/* FIXME: Add some programmer IDs here */
+const struct dev_entry devs_raiden[] = {
+ {0},
+};
+
#define GOOGLE_VID (0x18D1)
#define GOOGLE_RAIDEN_SPI_SUBCLASS (0x51)
#define GOOGLE_RAIDEN_SPI_PROTOCOL (0x01)

To view, visit change 39826. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: Ie4171a11384c34abb102d1aadf86aa1b8829fc04
Gerrit-Change-Number: 39826
Gerrit-PatchSet: 1
Gerrit-Owner: Angel Pons <th3fanbus@gmail.com>
Gerrit-MessageType: newchange