From: lokilee73 Date: Tue, 19 Dec 2017 08:01:43 +0000 (+0900) Subject: Check if device is opened in getting active configuration X-Git-Tag: submit/tizen_4.0/20171219.084427^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=938f57baf16dc1face9bc3d013c1c9df76b3cad6;p=platform%2Fcore%2Fapi%2Fusb-host.git Check if device is opened in getting active configuration Change-Id: Ifca3566ea75186363b98eb219cf5f1c04190a209 --- diff --git a/include/usb_host.h b/include/usb_host.h index ac6c91a..389d325 100755 --- a/include/usb_host.h +++ b/include/usb_host.h @@ -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. diff --git a/src/usb_host.c b/src/usb_host.c index 079862a..5a5f2f1 100755 --- a/src/usb_host.c +++ b/src/usb_host.c @@ -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