]> sigrok.org Git - libsigrok.git/commitdiff
Check usb_get_port_path() return value
authorRomain Tartière <redacted>
Tue, 28 Nov 2017 19:07:29 +0000 (20:07 +0100)
committerUwe Hermann <redacted>
Wed, 21 Feb 2018 10:37:19 +0000 (11:37 +0100)
This function can fail. If so, do not ignore the failure.

17 files changed:
src/device.c
src/hardware/chronovu-la/api.c
src/hardware/dreamsourcelab-dslogic/api.c
src/hardware/dreamsourcelab-dslogic/protocol.c
src/hardware/fx2lafw/api.c
src/hardware/fx2lafw/protocol.c
src/hardware/hantek-4032l/api.c
src/hardware/hantek-6xxx/api.c
src/hardware/hantek-6xxx/protocol.c
src/hardware/hantek-dso/api.c
src/hardware/hantek-dso/protocol.c
src/hardware/lecroy-logicstudio/api.c
src/hardware/saleae-logic-pro/api.c
src/hardware/saleae-logic16/api.c
src/hardware/testo/api.c
src/hardware/victor-dmm/api.c
src/hardware/zeroplus-logic-cube/api.c

index 6fcad410f2bc3802f979f7bb2f9687b755861940..519a1726399b060719df6c43f2432900266e3273 100644 (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;
                }
index fb35879fb3e000f690ce27cbfe2fc0d35e2b01ed..694bd54ac84fb91f0f864cefa67d9d31eb2a641c 100644 (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;
index a7eb1948d46ae951c03d76a2a46e4db33c048586..08d9f0b6dc348c26c371603c5605d95e7cc4af38 100644 (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++) {
index 2096073c1000c3c866d35133995d4d10498f89f2..0f171518125c5aa320ba0791de3a875df182f8d9 100644 (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;
index abb867884ed0ba9ae8e10acf242487f829f45c41..647aeec04d35522c11ba2cf80bec6899629b0a82 100644 (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++) {
index fc6fd3315a2c2ab6f76a3612e7e30db1362888f0..ec2b5c011b27ab94add03bfde6e211c2f76ef3f9 100644 (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;
index 626175f07873dd5daa99a23ca881edb72f21c262..67dc968dcaea91c423ceb0382607982ffa0f1154 100644 (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;
index 01cba5669b920ca601a1bafdf5cfd6e45420f85a..899dc86716bfc49c75b7a19f108b780c13c607d7 100644 (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++) {
index 8e406ffe03f04db5220cfccc18653ac10b72d024..75d8ab91c0f14fb4c2cfed4ce2222173e53f4660 100644 (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;
index 48beebfcadce98de9217bb6124a807c7e8881555..abbeb21b207aef72c3795c0a5d162bfd069b4100 100644 (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++) {
index 39d87c4433bb316564e0cdff84df818b76c2f808..c74187ada435f2441e7aa3b88ed926194c9d530b 100644 (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;
index 6dd0bd0179fa7f8354567f24eb537f240fec60e9..e75b5b09e97bc5a1d7090b9b6b9e484a87aba125 100644 (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
index a7e04548eff453cc25d113f7e8a05a4e32ab8e23..ae444dd832125bea1ff16880936f3ee5cf9b04f0 100644 (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;
index dedb9a244a2c637e59766125d2bfd801662314f2..ed9e1ecde9013a51d89e99c22af67f2b23c76d25 100644 (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;
index 90fb65ca4bed4a11f0c3296d766ca57a4f3947c2..43a5f2513f67ca4822356fa00e74e5b52fd5e150 100644 (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"))
index 6a9b774fc98d6988a8e4b2f0083585cdd9a1e170..d415a3f9cc86c4809db8dd44898a1c222dec3d19 100644 (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;
index da3899dd404d217de644efb0ad671e35b66d6aee..c2d1424b428872e00798bc3583abe7c33eb0f438 100644 (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++) {