summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAmir Hammad <amir.hammad@hotmail.com>2015-07-13 16:17:28 +0200
committerAmir Hammad <amir.hammad@hotmail.com>2015-07-13 16:17:28 +0200
commitf8658f941129ab929baacf0e6c1b2092a387d132 (patch)
tree710b5c95b6646f440e6710d95e03a788b12c3cd1
parent3003006216579428ee255073743321390400a8dc (diff)
downloadsecure-hid-f8658f941129ab929baacf0e6c1b2092a387d132.tar.gz
secure-hid-f8658f941129ab929baacf0e6c1b2092a387d132.tar.bz2
secure-hid-f8658f941129ab929baacf0e6c1b2092a387d132.zip
mouse: Do not allow unitialized driver to be loaded
Signed-off-by: Amir Hammad <amir.hammad@hotmail.com>
-rw-r--r--src/usbh_driver_hid_mouse.c10
1 files changed, 9 insertions, 1 deletions
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 <stdint.h>
-
+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;