Check usb_get_port_path() return value

This function can fail. If so, do not ignore the failure.
This commit is contained in:
Romain Tartière 2017-11-28 20:07:29 +01:00 committed by Uwe Hermann
parent 7bbe5a2b6a
commit 6c1a76d126
17 changed files with 44 additions and 19 deletions

View File

@ -753,7 +753,9 @@ SR_API const char *sr_dev_inst_connid_get(const struct sr_dev_inst *sdi)
if (b != usb->bus || a != usb->address)
continue;
usb_get_port_path(devlist[i], connection_id, sizeof(connection_id));
if (usb_get_port_path(devlist[i], connection_id, sizeof(connection_id)) < 0)
continue;
((struct sr_dev_inst *)sdi)->connection_id = g_strdup(connection_id);
break;
}

View File

@ -194,7 +194,8 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
libusb_close(hdl);
usb_get_port_path(devlist[i], connection_id, sizeof(connection_id));
if (usb_get_port_path(devlist[i], connection_id, sizeof(connection_id)) < 0)
continue;
if (!strcmp(product, "ChronoVu LA8"))
model = 0;

View File

@ -216,7 +216,8 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
libusb_close(hdl);
usb_get_port_path(devlist[i], connection_id, sizeof(connection_id));
if (usb_get_port_path(devlist[i], connection_id, sizeof(connection_id)) < 0)
continue;
prof = NULL;
for (j = 0; supported_device[j].vid; j++) {

View File

@ -568,7 +568,9 @@ SR_PRIV int dslogic_dev_open(struct sr_dev_inst *sdi, struct sr_dev_driver *di)
if ((sdi->status == SR_ST_INITIALIZING) ||
(sdi->status == SR_ST_INACTIVE)) {
/* Check device by its physical USB bus/port address. */
usb_get_port_path(devlist[i], connection_id, sizeof(connection_id));
if (usb_get_port_path(devlist[i], connection_id, sizeof(connection_id)) < 0)
continue;
if (strcmp(sdi->connection_id, connection_id))
/* This is not the one. */
continue;

View File

@ -265,7 +265,8 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
libusb_close(hdl);
usb_get_port_path(devlist[i], connection_id, sizeof(connection_id));
if (usb_get_port_path(devlist[i], connection_id, sizeof(connection_id)) < 0)
continue;
prof = NULL;
for (j = 0; supported_fx2[j].vid; j++) {

View File

@ -174,7 +174,9 @@ SR_PRIV int fx2lafw_dev_open(struct sr_dev_inst *sdi, struct sr_dev_driver *di)
/*
* Check device by its physical USB bus/port address.
*/
usb_get_port_path(devlist[i], connection_id, sizeof(connection_id));
if (usb_get_port_path(devlist[i], connection_id, sizeof(connection_id)) < 0)
continue;
if (strcmp(sdi->connection_id, connection_id))
/* This is not the one. */
continue;

View File

@ -180,7 +180,8 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
des.idProduct != H4032L_USB_PRODUCT)
continue;
usb_get_port_path(devlist[i], connection_id, sizeof(connection_id));
if (usb_get_port_path(devlist[i], connection_id, sizeof(connection_id)) < 0)
continue;
sdi = g_malloc0(sizeof(struct sr_dev_inst));
sdi->driver = &hantek_4032l_driver_info;

View File

@ -217,7 +217,8 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
libusb_get_device_descriptor(devlist[i], &des);
usb_get_port_path(devlist[i], connection_id, sizeof(connection_id));
if (usb_get_port_path(devlist[i], connection_id, sizeof(connection_id)) < 0)
continue;
prof = NULL;
for (j = 0; dev_profiles[j].orig_vid; j++) {

View File

@ -46,7 +46,9 @@ SR_PRIV int hantek_6xxx_open(struct sr_dev_inst *sdi)
/*
* Check device by its physical USB bus/port address.
*/
usb_get_port_path(devlist[i], connection_id, sizeof(connection_id));
if (usb_get_port_path(devlist[i], connection_id, sizeof(connection_id)) < 0)
continue;
if (strcmp(sdi->connection_id, connection_id))
/* This is not the one. */
continue;

View File

@ -315,7 +315,8 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
libusb_get_device_descriptor(devlist[i], &des);
usb_get_port_path(devlist[i], connection_id, sizeof(connection_id));
if (usb_get_port_path(devlist[i], connection_id, sizeof(connection_id)) < 0)
continue;
prof = NULL;
for (j = 0; dev_profiles[j].orig_vid; j++) {

View File

@ -130,7 +130,9 @@ SR_PRIV int dso_open(struct sr_dev_inst *sdi)
/*
* Check device by its physical USB bus/port address.
*/
usb_get_port_path(devlist[i], connection_id, sizeof(connection_id));
if (usb_get_port_path(devlist[i], connection_id, sizeof(connection_id)) < 0)
continue;
if (strcmp(sdi->connection_id, connection_id))
/* This is not the one. */
continue;

View File

@ -134,7 +134,8 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
if (des.idVendor != LOGICSTUDIO16_VID)
continue;
usb_get_port_path(devlist[i], connection_id, sizeof(connection_id));
if (usb_get_port_path(devlist[i], connection_id, sizeof(connection_id)) < 0)
continue;
usb = NULL;
@ -210,7 +211,8 @@ static int open_device(struct sr_dev_inst *sdi)
des.idProduct != LOGICSTUDIO16_PID_HAVE_FIRMWARE)
continue;
usb_get_port_path(devlist[i], connection_id, sizeof(connection_id));
if (usb_get_port_path(devlist[i], connection_id, sizeof(connection_id)) < 0)
continue;
/*
* Check if this device is the same one that we associated

View File

@ -240,7 +240,8 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
if (des.idVendor != 0x21a9 || des.idProduct != 0x1006)
continue;
usb_get_port_path(devlist[i], connection_id, sizeof(connection_id));
if (usb_get_port_path(devlist[i], connection_id, sizeof(connection_id)) < 0)
continue;
sdi = g_malloc0(sizeof(struct sr_dev_inst));
sdi->status = SR_ST_INITIALIZING;

View File

@ -188,7 +188,8 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
libusb_get_device_descriptor(devlist[i], &des);
usb_get_port_path(devlist[i], connection_id, sizeof(connection_id));
if (usb_get_port_path(devlist[i], connection_id, sizeof(connection_id)) < 0)
continue;
if (des.idVendor != LOGIC16_VID || des.idProduct != LOGIC16_PID)
continue;
@ -266,7 +267,9 @@ static int logic16_dev_open(struct sr_dev_inst *sdi)
/*
* Check device by its physical USB bus/port address.
*/
usb_get_port_path(devlist[i], connection_id, sizeof(connection_id));
if (usb_get_port_path(devlist[i], connection_id, sizeof(connection_id)) < 0)
continue;
if (strcmp(sdi->connection_id, connection_id))
/* This is not the one. */
continue;

View File

@ -109,7 +109,8 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
if (strncmp(manufacturer, "testo", 5))
continue;
usb_get_port_path(devlist[i], connection_id, sizeof(connection_id));
if (usb_get_port_path(devlist[i], connection_id, sizeof(connection_id)) < 0)
continue;
/* Hardcode the 435 for now. */
if (strcmp(product, "testo 435/635/735"))

View File

@ -69,7 +69,8 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
if (des.idVendor != VICTOR_VID || des.idProduct != VICTOR_PID)
continue;
usb_get_port_path(devlist[i], connection_id, sizeof(connection_id));
if (usb_get_port_path(devlist[i], connection_id, sizeof(connection_id)) < 0)
continue;
sdi = g_malloc0(sizeof(struct sr_dev_inst));
sdi->status = SR_ST_INACTIVE;

View File

@ -196,7 +196,8 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
libusb_close(hdl);
usb_get_port_path(devlist[i], connection_id, sizeof(connection_id));
if (usb_get_port_path(devlist[i], connection_id, sizeof(connection_id)) < 0)
continue;
prof = NULL;
for (j = 0; j < zeroplus_models[j].vid; j++) {