mirror of
https://review.coreboot.org/flashrom.git
synced 2025-04-27 15:12:36 +02:00
ft2232_spi: Normalize error paths in ft2232_shutdown()
We missed to `free(spi_data)` on one path. It also seems odd to leak the return code of a locally used library into our common infrastruc- ture, so normalize all error paths to return 1. Change-Id: I5158d06127a9a8934b083e48b69d29c4d5a11831 Signed-off-by: Nico Huber <nico.h@gmx.de> Reviewed-on: https://review.coreboot.org/c/flashrom/+/55696 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Angel Pons <th3fanbus@gmail.com> Reviewed-by: Anastasia Klimchuk <aklm@chromium.org> Reviewed-by: Edward O'Callaghan <quasisec@chromium.org>
This commit is contained in:
parent
f0915dbc6b
commit
e1e0c597db
12
ft2232_spi.c
12
ft2232_spi.c
@ -170,10 +170,10 @@ static int get_buf(struct ftdi_context *ftdic, const unsigned char *buf,
|
|||||||
|
|
||||||
static int ft2232_shutdown(void *data)
|
static int ft2232_shutdown(void *data)
|
||||||
{
|
{
|
||||||
int f;
|
|
||||||
struct ft2232_data *spi_data = (struct ft2232_data *) data;
|
struct ft2232_data *spi_data = (struct ft2232_data *) data;
|
||||||
struct ftdi_context *ftdic = &spi_data->ftdic_context;
|
struct ftdi_context *ftdic = &spi_data->ftdic_context;
|
||||||
unsigned char buf[3];
|
unsigned char buf[3];
|
||||||
|
int ret = 0;
|
||||||
|
|
||||||
msg_pdbg("Releasing I/Os\n");
|
msg_pdbg("Releasing I/Os\n");
|
||||||
buf[0] = SET_BITS_LOW;
|
buf[0] = SET_BITS_LOW;
|
||||||
@ -182,16 +182,18 @@ static int ft2232_shutdown(void *data)
|
|||||||
if (send_buf(ftdic, buf, 3)) {
|
if (send_buf(ftdic, buf, 3)) {
|
||||||
msg_perr("Unable to set pins back inputs: (%s)\n",
|
msg_perr("Unable to set pins back inputs: (%s)\n",
|
||||||
ftdi_get_error_string(ftdic));
|
ftdi_get_error_string(ftdic));
|
||||||
|
ret = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((f = ftdi_usb_close(ftdic)) < 0) {
|
const int close_ret = ftdi_usb_close(ftdic);
|
||||||
msg_perr("Unable to close FTDI device: %d (%s)\n", f,
|
if (close_ret < 0) {
|
||||||
|
msg_perr("Unable to close FTDI device: %d (%s)\n", close_ret,
|
||||||
ftdi_get_error_string(ftdic));
|
ftdi_get_error_string(ftdic));
|
||||||
return f;
|
ret = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
free(spi_data);
|
free(spi_data);
|
||||||
return 0;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool ft2232_spi_command_fits(const struct spi_command *cmd, size_t buffer_size)
|
static bool ft2232_spi_command_fits(const struct spi_command *cmd, size_t buffer_size)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user