Edward O'Callaghan submitted this change.

View Change

Approvals: build bot (Jenkins): Verified Sam McNally: Looks good to me, approved
realtek_mst_i2c_spi.c: Fixup get_params() err ctrl flow

Ensure that when bus number and reset params are specified
at the same time are both correctly parsed by get_params().
Also renames the goto err cleanup path to make it clear.

Change-Id: Icb45b1ab39181b0f1a2dec1cce549d30db984936
Signed-off-by: Edward O'Callaghan <quasisec@google.com>
Spotted-by: Shiyu Sun <sshiyu@google.com>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/45944
Reviewed-by: Sam McNally <sammc@google.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
---
M realtek_mst_i2c_spi.c
1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/realtek_mst_i2c_spi.c b/realtek_mst_i2c_spi.c
index e975290..d1f7227 100644
--- a/realtek_mst_i2c_spi.c
+++ b/realtek_mst_i2c_spi.c
@@ -416,23 +416,22 @@
int bus = (int)strtol(bus_str, &bus_suffix, 10);
if (errno != 0 || bus_str == bus_suffix) {
msg_perr("%s: Could not convert 'bus'.\n", __func__);
- goto get_params_done;
+ goto _get_params_failed;
}

if (bus < 0 || bus > 255) {
msg_perr("%s: Value for 'bus' is out of range(0-255).\n", __func__);
- goto get_params_done;
+ goto _get_params_failed;
}

if (strlen(bus_suffix) > 0) {
msg_perr("%s: Garbage following 'bus' value.\n", __func__);
- goto get_params_done;
+ goto _get_params_failed;
}

msg_pinfo("Using i2c bus %i.\n", bus);
*i2c_bus = bus;
ret = 0;
- goto get_params_done;
} else {
msg_perr("%s: Bus number not specified.\n", __func__);
}
@@ -451,7 +450,7 @@
*reset = 0; /* Default behaviour is no MCU reset on tear-down. */
free(reset_str);

-get_params_done:
+_get_params_failed:
if (bus_str)
free(bus_str);


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

Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: Icb45b1ab39181b0f1a2dec1cce549d30db984936
Gerrit-Change-Number: 45944
Gerrit-PatchSet: 3
Gerrit-Owner: Edward O'Callaghan <quasisec@chromium.org>
Gerrit-Reviewer: Edward O'Callaghan <quasisec@chromium.org>
Gerrit-Reviewer: Sam McNally <sammc@google.com>
Gerrit-Reviewer: Shiyu Sun <sshiyu@google.com>
Gerrit-Reviewer: build bot (Jenkins) <no-reply@coreboot.org>
Gerrit-MessageType: merged