From 3003006216579428ee255073743321390400a8dc Mon Sep 17 00:00:00 2001 From: Amir Hammad Date: Mon, 13 Jul 2015 16:16:39 +0200 Subject: hub: Do not allow unitialized driver to be loaded Signed-off-by: Amir Hammad --- src/usbh_driver_hub.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/usbh_driver_hub.c b/src/usbh_driver_hub.c index 266cd71..7678dd7 100644 --- a/src/usbh_driver_hub.c +++ b/src/usbh_driver_hub.c @@ -31,12 +31,14 @@ static hub_device_t hub_device[USBH_MAX_HUBS]; static void event(usbh_device_t *dev, usbh_packet_callback_data_t cb_data); - +static bool initialized = false; void hub_driver_init(void) { uint32_t i; + initialized = true; + for (i = 0; i < USBH_MAX_HUBS; i++) { hub_device[i].device[0] = 0; hub_device[i].ports_num = 0; @@ -51,6 +53,11 @@ void hub_driver_init(void) */ static void *init(void *usbh_dev) { + if (!initialized) { + LOG_PRINTF("\n%s/%d : driver not initialized\r\n", __FILE__, __LINE__); + return 0; + } + uint32_t i; hub_device_t *drvdata = 0; // find free data space for hub device -- cgit