1
0
mirror of https://review.coreboot.org/flashrom.git synced 2025-04-27 07:02:34 +02:00

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>
This commit is contained in:
Edward O'Callaghan 2020-10-02 12:40:11 +10:00 committed by Edward O'Callaghan
parent 3ba19b3148
commit 90ac9872cd

View File

@ -416,23 +416,22 @@ static int get_params(int *i2c_bus, int *reset)
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 @@ static int get_params(int *i2c_bus, int *reset)
*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);