mirror of
https://review.coreboot.org/flashrom.git
synced 2025-04-27 23:22:37 +02:00
tree: Check properly if libusb is initialized
The dediprog, developerbox_spi and stlinkv3_spi programmers only check if the libusb_context is not NULL after the initialization. But following the API documentation from libusb, the context is undefined unless the init function returns 0. Fix this by checking the return value instead of the libusb_context to see if the initialization was successful. https://libusb.sourceforge.io/api-1.0/group__libusb__lib.html Change-Id: Ia45ccd3fa2239dfccd821be46a09c86426cb22e5 Signed-off-by: Thomas Heijligen <thomas.heijligen@secunet.com> Reviewed-on: https://review.coreboot.org/c/flashrom/+/66460 Reviewed-by: Felix Singer <felixsinger@posteo.net> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
This commit is contained in:
parent
7346cda9e9
commit
374871c039
@ -1206,8 +1206,8 @@ static int dediprog_init(void)
|
||||
dp_data->devicetype = DEV_UNKNOWN;
|
||||
|
||||
/* Here comes the USB stuff. */
|
||||
libusb_init(&dp_data->usb_ctx);
|
||||
if (!dp_data->usb_ctx) {
|
||||
ret = libusb_init(&dp_data->usb_ctx);
|
||||
if (ret) {
|
||||
msg_perr("Could not initialize libusb!\n");
|
||||
goto init_err_exit;
|
||||
}
|
||||
|
@ -147,8 +147,7 @@ static int developerbox_spi_init(void)
|
||||
struct libusb_context *usb_ctx;
|
||||
libusb_device_handle *cp210x_handle;
|
||||
|
||||
libusb_init(&usb_ctx);
|
||||
if (!usb_ctx) {
|
||||
if (libusb_init(&usb_ctx)) {
|
||||
msg_perr("Could not initialize libusb!\n");
|
||||
return 1;
|
||||
}
|
||||
|
@ -485,8 +485,7 @@ static int stlinkv3_spi_init(void)
|
||||
libusb_device_handle *stlinkv3_handle;
|
||||
struct stlinkv3_spi_data *stlinkv3_data;
|
||||
|
||||
libusb_init(&usb_ctx);
|
||||
if (!usb_ctx) {
|
||||
if (libusb_init(&usb_ctx)) {
|
||||
msg_perr("Could not initialize libusb!\n");
|
||||
return 1;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user