Check if device is opened in getting active configuration 95/159695/1
authorPaweł Szewczyk <p.szewczyk@samsung.com>
Fri, 3 Nov 2017 09:37:46 +0000 (10:37 +0100)
committerPaweł Szewczyk <p.szewczyk@samsung.com>
Fri, 10 Nov 2017 16:55:49 +0000 (17:55 +0100)
Change-Id: Ice65b6724f57d96b9af01c656a3df509a864b958
Signed-off-by: Paweł Szewczyk <p.szewczyk@samsung.com>
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