summaryrefslogtreecommitdiffstats
path: root/dediprog.c
diff options
context:
space:
mode:
authorThomas Heijligen <thomas.heijligen@secunet.com>2022-08-05 17:56:20 +0200
committerThomas Heijligen <src@posteo.de>2022-08-23 08:40:50 +0000
commit374871c0393bb1d67c36dc9b7280d8e5f8b22ad5 (patch)
tree1a47dea0fc467514aac4759c62df121b005fbaf1 /dediprog.c
parent7346cda9e934cc71708efddba7a24e83f546992c (diff)
downloadflashrom-374871c0393bb1d67c36dc9b7280d8e5f8b22ad5.tar.gz
flashrom-374871c0393bb1d67c36dc9b7280d8e5f8b22ad5.tar.bz2
flashrom-374871c0393bb1d67c36dc9b7280d8e5f8b22ad5.zip
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>
Diffstat (limited to 'dediprog.c')
-rw-r--r--dediprog.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/dediprog.c b/dediprog.c
index 519a8b0d6..e5bf84e39 100644
--- a/dediprog.c
+++ b/dediprog.c
@@ -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;
}