From f8658f941129ab929baacf0e6c1b2092a387d132 Mon Sep 17 00:00:00 2001 From: Amir Hammad Date: Mon, 13 Jul 2015 16:17:28 +0200 Subject: mouse: Do not allow unitialized driver to be loaded Signed-off-by: Amir Hammad --- src/usbh_driver_hid_mouse.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/usbh_driver_hid_mouse.c b/src/usbh_driver_hid_mouse.c index dc6ab84..0a575f2 100644 --- a/src/usbh_driver_hid_mouse.c +++ b/src/usbh_driver_hid_mouse.c @@ -56,11 +56,14 @@ static const hid_mouse_config_t *mouse_config; #include - +static bool initialized = false; void hid_mouse_driver_init(const hid_mouse_config_t *config) { uint32_t i; + + initialized = true; + mouse_config = config; for (i = 0; i < USBH_HID_MOUSE_MAX_DEVICES; i++) { mouse_device[i].state_next = STATE_INACTIVE; @@ -73,6 +76,11 @@ void hid_mouse_driver_init(const hid_mouse_config_t *config) */ 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; hid_mouse_device_t *drvdata = 0; -- cgit