Felix Singer has submitted this change. ( https://review.coreboot.org/c/flashrom/+/67621 )
Change subject: Revert "flashrom.c: Remove programmer_param global state"
......................................................................
Revert "flashrom.c: Remove programmer_param global state"
This reverts commit 3b8b93e17f6ad861acb2a0810ae1dcf03285fb10.
Invoking flashrom with no parameters crashes when calling strdup(NULL)
in programmer_init().
Change-Id: I3b689ad4bdd0c9c3b11f30becafc878c78630f0b
Signed-off-by: Thomas Heijligen <thomas.heijligen(a)secunet.com>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/67621
Tested-by: build bot (Jenkins) <no-reply(a)coreboot.org>
Reviewed-by: Angel Pons <th3fanbus(a)gmail.com>
Reviewed-by: Felix Singer <felixsinger(a)posteo.net>
Reviewed-by: Nico Huber <nico.h(a)gmx.de>
Reviewed-by: Jonathon Hall <jonathon.hall(a)puri.sm>
Reviewed-by: Anastasia Klimchuk <aklm(a)chromium.org>
Reviewed-by: Edward O'Callaghan <quasisec(a)chromium.org>
---
M flashrom.c
1 file changed, 48 insertions(+), 27 deletions(-)
Approvals:
build bot (Jenkins): Verified
Nico Huber: Looks good to me, but someone else must approve
Felix Singer: Looks good to me, approved
Angel Pons: Looks good to me, approved
Edward O'Callaghan: Looks good to me, approved
Anastasia Klimchuk: Looks good to me, approved
Jonathon Hall: Looks good to me, but someone else must approve
diff --git a/flashrom.c b/flashrom.c
index ec16d04..b68ba55 100644
--- a/flashrom.c
+++ b/flashrom.c
@@ -38,6 +38,7 @@
const char *chip_to_probe = NULL;
static const struct programmer_entry *programmer = NULL;
+static const char *programmer_param = NULL;
/*
* Programmers supporting multiple buses can have differing size limits on
@@ -125,28 +126,10 @@
return rc;
}
-static int get_param_residue(const char *prog_params, int ret)
-{
- if (prog_params && strlen(prog_params)) {
- if (ret != 0) {
- /* It is quite possible that any unhandled programmer parameter would have been valid,
- * but an error in actual programmer init happened before the parameter was evaluated.
- */
- msg_pwarn("Unhandled programmer parameters (possibly due to another failure): %s\n", prog_params);
- } else {
- /* Actual programmer init was successful, but the user specified an invalid or unusable
- * (for the current programmer configuration) parameter.
- */
- msg_perr("Unhandled programmer parameters: %s\n", prog_params);
- msg_perr("Aborting.\n");
- ret = ERROR_FATAL;
- }
- }
- return ret;
-}
-
int programmer_init(const struct programmer_entry *prog, const char *param)
{
+ int ret;
+
if (prog == NULL) {
msg_perr("Invalid programmer specified!\n");
return -1;
@@ -167,11 +150,25 @@
/* Default to allowing writes. Broken programmers set this to 0. */
programmer_may_write = true;
- msg_pdbg("Initializing %s programmer\n", prog->name);
- const struct programmer_cfg cfg = { .params = strdup(param) };
- int ret = prog->init(&cfg);
- ret = get_param_residue(cfg.params, ret);
- free(cfg.params);
+ programmer_param = param;
+ msg_pdbg("Initializing %s programmer\n", programmer->name);
+ ret = programmer->init(NULL);
+ if (programmer_param && strlen(programmer_param)) {
+ if (ret != 0) {
+ /* It is quite possible that any unhandled programmer parameter would have been valid,
+ * but an error in actual programmer init happened before the parameter was evaluated.
+ */
+ msg_pwarn("Unhandled programmer parameters (possibly due to another failure): %s\n",
+ programmer_param);
+ } else {
+ /* Actual programmer init was successful, but the user specified an invalid or unusable
+ * (for the current programmer configuration) parameter.
+ */
+ msg_perr("Unhandled programmer parameters: %s\n", programmer_param);
+ msg_perr("Aborting.\n");
+ ret = ERROR_FATAL;
+ }
+ }
return ret;
}
@@ -191,6 +188,7 @@
ret |= shutdown_fn[i].func(shutdown_fn[i].data);
}
+ programmer_param = NULL;
registered_master_count = 0;
return ret;
@@ -229,7 +227,7 @@
* needle and remove everything from the first occurrence of needle to the next
* delimiter from haystack.
*/
-static char *extract_param(char *const *haystack, const char *needle, const char *delim)
+static char *extract_param(const char *const *haystack, const char *needle, const char *delim)
{
char *param_pos, *opt_pos, *rest;
char *opt = NULL;
@@ -287,7 +285,7 @@
char *extract_programmer_param_str(const struct programmer_cfg *cfg, const char *param_name)
{
- return extract_param(&cfg->params, param_name, ",");
+ return extract_param(&programmer_param, param_name, ",");
}
static int check_block_eraser(const struct flashctx *flash, int k, int log)
--
To view, visit https://review.coreboot.org/c/flashrom/+/67621
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: I3b689ad4bdd0c9c3b11f30becafc878c78630f0b
Gerrit-Change-Number: 67621
Gerrit-PatchSet: 2
Gerrit-Owner: Thomas Heijligen <src(a)posteo.de>
Gerrit-Reviewer: Anastasia Klimchuk <aklm(a)chromium.org>
Gerrit-Reviewer: Angel Pons <th3fanbus(a)gmail.com>
Gerrit-Reviewer: Edward O'Callaghan <quasisec(a)chromium.org>
Gerrit-Reviewer: Felix Singer <felixsinger(a)posteo.net>
Gerrit-Reviewer: Jonathon Hall <jonathon.hall(a)puri.sm>
Gerrit-Reviewer: Nico Huber <nico.h(a)gmx.de>
Gerrit-Reviewer: build bot (Jenkins) <no-reply(a)coreboot.org>
Gerrit-MessageType: merged
Attention is currently required from: Nico Huber, Thomas Heijligen, Angel Pons, Anastasia Klimchuk.
Felix Singer has posted comments on this change. ( https://review.coreboot.org/c/flashrom/+/66475 )
Change subject: test_build.sh: Build all programmers individually using Meson
......................................................................
Patch Set 13:
(2 comments)
Commit Message:
https://review.coreboot.org/c/flashrom/+/66475/comment/9850fd64_58875d7e
PS2, Line 8:
> Yes, I intended to do that later. I just wanted to draft a first version of it. 😊 […]
I guess I can mark this as done 😋
File test_build.sh:
https://review.coreboot.org/c/flashrom/+/66475/comment/725db3ab_ea77295e
PS12, Line 48: local
> I think we've said not to use `local` to be compatible with non bash shells
I forgot that, sorry. Done.
--
To view, visit https://review.coreboot.org/c/flashrom/+/66475
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: I703127a2dc31d316d3d1c842b5bcb0b22c39c0d4
Gerrit-Change-Number: 66475
Gerrit-PatchSet: 13
Gerrit-Owner: Felix Singer <felixsinger(a)posteo.net>
Gerrit-Reviewer: Anastasia Klimchuk <aklm(a)chromium.org>
Gerrit-Reviewer: Angel Pons <th3fanbus(a)gmail.com>
Gerrit-Reviewer: Nico Huber <nico.h(a)gmx.de>
Gerrit-Reviewer: Thomas Heijligen <src(a)posteo.de>
Gerrit-Reviewer: build bot (Jenkins) <no-reply(a)coreboot.org>
Gerrit-Attention: Nico Huber <nico.h(a)gmx.de>
Gerrit-Attention: Thomas Heijligen <src(a)posteo.de>
Gerrit-Attention: Angel Pons <th3fanbus(a)gmail.com>
Gerrit-Attention: Anastasia Klimchuk <aklm(a)chromium.org>
Gerrit-Comment-Date: Wed, 14 Sep 2022 03:28:45 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Felix Singer <felixsinger(a)posteo.net>
Comment-In-Reply-To: Thomas Heijligen <src(a)posteo.de>
Comment-In-Reply-To: Anastasia Klimchuk <aklm(a)chromium.org>
Gerrit-MessageType: comment
Attention is currently required from: Felix Singer, Nico Huber, Angel Pons.
Hello build bot (Jenkins), Nico Huber, Thomas Heijligen, Angel Pons, Anastasia Klimchuk,
I'd like you to reexamine a change. Please visit
https://review.coreboot.org/c/flashrom/+/66475
to look at the new patch set (#13).
Change subject: test_build.sh: Build all programmers individually using Meson
......................................................................
test_build.sh: Build all programmers individually using Meson
The test build script already builds each programmer individually when
Make is used. To check if the Meson build system is working properly,
also build each programmer individually and in addition to that
build-test the programmer groups individually.
Builds are done in the directory `out`, while for each build a new
subdirectory with the name of the programmer option is created.
Also, return when scan-build is used and not the group `all` is
selected, since it's not needed to run scan-build in combination with
the other options.
Signed-off-by: Felix Singer <felixsinger(a)posteo.net>
Change-Id: I703127a2dc31d316d3d1c842b5bcb0b22c39c0d4
---
M test_build.sh
1 file changed, 45 insertions(+), 3 deletions(-)
git pull ssh://review.coreboot.org:29418/flashrom refs/changes/75/66475/13
--
To view, visit https://review.coreboot.org/c/flashrom/+/66475
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: I703127a2dc31d316d3d1c842b5bcb0b22c39c0d4
Gerrit-Change-Number: 66475
Gerrit-PatchSet: 13
Gerrit-Owner: Felix Singer <felixsinger(a)posteo.net>
Gerrit-Reviewer: Anastasia Klimchuk <aklm(a)chromium.org>
Gerrit-Reviewer: Angel Pons <th3fanbus(a)gmail.com>
Gerrit-Reviewer: Nico Huber <nico.h(a)gmx.de>
Gerrit-Reviewer: Thomas Heijligen <src(a)posteo.de>
Gerrit-Reviewer: build bot (Jenkins) <no-reply(a)coreboot.org>
Gerrit-Attention: Felix Singer <felixsinger(a)posteo.net>
Gerrit-Attention: Nico Huber <nico.h(a)gmx.de>
Gerrit-Attention: Angel Pons <th3fanbus(a)gmail.com>
Gerrit-MessageType: newpatchset
Attention is currently required from: Edward O'Callaghan, Anastasia Klimchuk.
Felix Singer has posted comments on this change. ( https://review.coreboot.org/c/flashrom/+/67643 )
Change subject: tests/parade_lspcon.c: Replace spaces with tabs
......................................................................
Patch Set 1: Code-Review+2
--
To view, visit https://review.coreboot.org/c/flashrom/+/67643
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: Ic3a7d3004b8358953917a6666bcf8f1cdade02fd
Gerrit-Change-Number: 67643
Gerrit-PatchSet: 1
Gerrit-Owner: Anastasia Klimchuk <aklm(a)chromium.org>
Gerrit-Reviewer: Edward O'Callaghan <quasisec(a)chromium.org>
Gerrit-Reviewer: Felix Singer <felixsinger(a)posteo.net>
Gerrit-Reviewer: build bot (Jenkins) <no-reply(a)coreboot.org>
Gerrit-Attention: Edward O'Callaghan <quasisec(a)chromium.org>
Gerrit-Attention: Anastasia Klimchuk <aklm(a)chromium.org>
Gerrit-Comment-Date: Wed, 14 Sep 2022 02:42:23 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment
Anastasia Klimchuk has uploaded this change for review. ( https://review.coreboot.org/c/flashrom/+/67643 )
Change subject: tests/parade_lspcon.c: Replace spaces with tabs
......................................................................
tests/parade_lspcon.c: Replace spaces with tabs
Spaces were accidentally introduced in previous commit, replacing
with tabs as it should be.
Change-Id: Ic3a7d3004b8358953917a6666bcf8f1cdade02fd
Signed-off-by: Anastasia Klimchuk <aklm(a)chromium.org>
---
M tests/parade_lspcon.c
1 file changed, 23 insertions(+), 10 deletions(-)
git pull ssh://review.coreboot.org:29418/flashrom refs/changes/43/67643/1
diff --git a/tests/parade_lspcon.c b/tests/parade_lspcon.c
index a1c9f72..9d7bd23 100644
--- a/tests/parade_lspcon.c
+++ b/tests/parade_lspcon.c
@@ -19,19 +19,19 @@
/* Same macros as in parade_lspcon.c programmer. */
/* FIXME(aklm): should driver register maps be defined in `include/drivers/` for sharing with tests? */
-#define REGISTER_ADDRESS 0x4a
-#define SPISTATUS 0x9e
-#define SPISTATUS_SECTOR_ERASE_FINISHED 0
-#define SWSPICTL 0x93
-#define SWSPICTL_ENABLE_READBACK 0x8
-#define SWSPI_RDATA 0x91
+#define REGISTER_ADDRESS 0x4a
+#define SPISTATUS 0x9e
+#define SPISTATUS_SECTOR_ERASE_FINISHED 0
+#define SWSPICTL 0x93
+#define SWSPICTL_ENABLE_READBACK 0x8
+#define SWSPI_RDATA 0x91
/* Macros for test run. */
-#define DATA_TO_READ 0
-#define MAX_REG_BUF_LEN 2
+#define DATA_TO_READ 0
+#define MAX_REG_BUF_LEN 2
struct parade_lspcon_io_state {
- unsigned long addr; /* Address to read and write */
- uint8_t reg_buf[MAX_REG_BUF_LEN]; /* Last value written to the register address */
+ unsigned long addr; /* Address to read and write */
+ uint8_t reg_buf[MAX_REG_BUF_LEN]; /* Last value written to the register address */
};
static int parade_lspcon_ioctl(void *state, int fd, unsigned long request, va_list args)
--
To view, visit https://review.coreboot.org/c/flashrom/+/67643
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: Ic3a7d3004b8358953917a6666bcf8f1cdade02fd
Gerrit-Change-Number: 67643
Gerrit-PatchSet: 1
Gerrit-Owner: Anastasia Klimchuk <aklm(a)chromium.org>
Gerrit-MessageType: newchange
Attention is currently required from: Thomas Heijligen, Angel Pons, Anastasia Klimchuk.
Edward O'Callaghan has posted comments on this change. ( https://review.coreboot.org/c/flashrom/+/67642 )
Change subject: tests: Add unit test for initialisation with NULL programmer param
......................................................................
Patch Set 1: Code-Review+2
(2 comments)
File tests/lifecycle.c:
https://review.coreboot.org/c/flashrom/+/67642/comment/92945296_31835f15
PS1, Line 42: ;
`= NULL;` and you can avoid the else branch.
https://review.coreboot.org/c/flashrom/+/67642/comment/413930a0_2d4df771
PS1, Line 44: if (param != NULL)
`if (param)` is sufficient and canonical.
--
To view, visit https://review.coreboot.org/c/flashrom/+/67642
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: I409f1c9ac832943e54107f7cf8652d1f46ac67df
Gerrit-Change-Number: 67642
Gerrit-PatchSet: 1
Gerrit-Owner: Anastasia Klimchuk <aklm(a)chromium.org>
Gerrit-Reviewer: Angel Pons <th3fanbus(a)gmail.com>
Gerrit-Reviewer: Edward O'Callaghan <quasisec(a)chromium.org>
Gerrit-Reviewer: Felix Singer <felixsinger(a)posteo.net>
Gerrit-Reviewer: Thomas Heijligen <src(a)posteo.de>
Gerrit-Reviewer: build bot (Jenkins) <no-reply(a)coreboot.org>
Gerrit-CC: Nico Huber <nico.h(a)gmx.de>
Gerrit-Attention: Thomas Heijligen <src(a)posteo.de>
Gerrit-Attention: Angel Pons <th3fanbus(a)gmail.com>
Gerrit-Attention: Anastasia Klimchuk <aklm(a)chromium.org>
Gerrit-Comment-Date: Wed, 14 Sep 2022 00:47:50 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment
Attention is currently required from: Jonathon Hall.
Edward O'Callaghan has posted comments on this change. ( https://review.coreboot.org/c/flashrom/+/67619 )
Change subject: flashrom.c: Don't crash when programmer parameter string is NULL
......................................................................
Patch Set 1:
(1 comment)
Commit Message:
https://review.coreboot.org/c/flashrom/+/67619/comment/269f14de_c7cb71d7
PS1, Line 9: commit 3b8b93e
> Thanks, closing
Jonathon, Thank you for preparing this patch.
Angel, Could you help outline what else is wrong with it so we can coverage that with a test?
--
To view, visit https://review.coreboot.org/c/flashrom/+/67619
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: Ie13bdcf63c23d912dc9b774ae279f1ae5883e287
Gerrit-Change-Number: 67619
Gerrit-PatchSet: 1
Gerrit-Owner: Jonathon Hall <jonathon.hall(a)puri.sm>
Gerrit-Reviewer: Anastasia Klimchuk <aklm(a)chromium.org>
Gerrit-Reviewer: Edward O'Callaghan <quasisec(a)chromium.org>
Gerrit-Reviewer: build bot (Jenkins) <no-reply(a)coreboot.org>
Gerrit-CC: Angel Pons <th3fanbus(a)gmail.com>
Gerrit-CC: Thomas Heijligen <src(a)posteo.de>
Gerrit-Attention: Jonathon Hall <jonathon.hall(a)puri.sm>
Gerrit-Comment-Date: Wed, 14 Sep 2022 00:42:51 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Thomas Heijligen <src(a)posteo.de>
Comment-In-Reply-To: Angel Pons <th3fanbus(a)gmail.com>
Comment-In-Reply-To: Jonathon Hall <jonathon.hall(a)puri.sm>
Gerrit-MessageType: comment