Edward O'Callaghan submitted this 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>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/39826
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Edward O'Callaghan <quasisec@chromium.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Paul Menzel <paulepanter@users.sourceforge.net>
---
M flashrom.c
M programmer.h
M raiden_debug_spi.c
3 files changed, 7 insertions(+), 1 deletion(-)
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.