Fix geting configuration from unconfigured device 86/135486/1
authorPaweł Szewczyk <p.szewczyk@samsung.com>
Mon, 19 Jun 2017 11:17:33 +0000 (13:17 +0200)
committerPaweł Szewczyk <p.szewczyk@samsung.com>
Thu, 22 Jun 2017 13:57:31 +0000 (15:57 +0200)
Device in unconfigured state does not have active configuration, but it
does not neccecarily means an error.

Change-Id: I90c581aed25175ff5f76140d33610a5d4b384ff6
Signed-off-by: Paweł Szewczyk <p.szewczyk@samsung.com>
src/usb_host.c

index 708e0bcab675827453ad1389bb77042afa041ac1..0e2356b50442ee8e9f611e5dd5a92ac48365455c 100644 (file)
@@ -835,6 +835,12 @@ int usb_host_get_active_config(usb_host_device_h dev, usb_host_config_h *config)
                goto out; //LCOV_EXCL_LINE System Error
        }
 
+       /* unconfigured state */
+       if (cfg_nmb == 0) {
+               config = NULL;
+               goto out;
+       }
+
        ret = libusb_get_config_descriptor_by_value(dev->lusb_dev, cfg_nmb, &lcfg_desc);
        if (ret < 0) {
                ret = translate_error(ret); //LCOV_EXCL_LINE System Error