From: Paweł Szewczyk
Date: Mon, 19 Jun 2017 11:17:33 +0000 (+0200)
Subject: Fix geting configuration from unconfigured device
X-Git-Tag: submit/tizen/20170905.070056~2
X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F86%2F135486%2F1;p=platform%2Fcore%2Fapi%2Fusb-host.git
Fix geting configuration from unconfigured device
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
---
diff --git a/src/usb_host.c b/src/usb_host.c
index 708e0bc..0e2356b 100644
--- a/src/usb_host.c
+++ b/src/usb_host.c
@@ -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