Check if device is opened in getting active configuration 72/164472/1 accepted/tizen/4.0/unified/20171219.183848 submit/tizen_4.0/20171219.084427 tizen_4.0.IoT.p2_release
authorlokilee73 <changjoo.lee@samsung.com>
Tue, 19 Dec 2017 08:01:43 +0000 (17:01 +0900)
committerlokilee73 <changjoo.lee@samsung.com>
Tue, 19 Dec 2017 08:01:43 +0000 (17:01 +0900)
Change-Id: Ifca3566ea75186363b98eb219cf5f1c04190a209

include/usb_host.h
src/usb_host.c

index ac6c91a7a0ad7e2ee1691d037c8d9e9c0941fb49..389d325b08f1acd6ecbdb9ff6b06ce19472d021a 100755 (executable)
@@ -415,6 +415,7 @@ int usb_host_device_get_config(usb_host_device_h dev, int config_index, usb_host
  * @retval #USB_HOST_ERROR_NO_SUCH_DEVICE the dev has been disconnected
  * @retval #USB_HOST_ERROR_INVALID_PARAMETER Invalid parameter was passed
  * @retval #USB_HOST_ERROR_NONE Successful
+ * @retval #USB_HOST_ERROR_DEVICE_NOT_OPENED The device was not opened
  * @retval #USB_HOST_ERROR_NOT_SUPPORTED Not supported
  * @post Obtained configuration should be destroyed by usb_host_config_destroy()
  * when no longer needed.
index 079862a5a4d08cf6a4db0f113b3a491bd063a2a5..5a5f2f1bed392092717123747e1142b9f8ca30b2 100755 (executable)
@@ -828,6 +828,11 @@ int usb_host_get_active_config(usb_host_device_h dev, usb_host_config_h *config)
                return USB_HOST_ERROR_INVALID_PARAMETER;
        }
 
+       if (dev->lusb_dev_handle == NULL) {
+               _E("Device is not opened");
+               return USB_HOST_ERROR_DEVICE_NOT_OPENED;
+       }
+
        ret = libusb_get_configuration(dev->lusb_dev_handle, &cfg_nmb);
        if (ret < 0) {
                ret = translate_error(ret); //LCOV_EXCL_LINE System Error