From 0a5c478b05e304b275fbe26e49124c2067a1357f Mon Sep 17 00:00:00 2001 From: schneider <schneider@blinkenlichts.net> Date: Wed, 23 Dec 2020 01:42:20 +0100 Subject: [PATCH] fix(hid): Don't crash when not enabled --- epicardium/ble/hid_work.c | 4 ++++ epicardium/epicardium.h | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/epicardium/ble/hid_work.c b/epicardium/ble/hid_work.c index 0f6dbdc9..f4eeb2e7 100644 --- a/epicardium/ble/hid_work.c +++ b/epicardium/ble/hid_work.c @@ -214,6 +214,10 @@ int epic_ble_hid_send_report(uint8_t report_id, uint8_t *data, uint8_t len) return -EIO; } + if (!queue) { + return -EIO; + } + int ret; ret = hid_queue_data(report_id, data, len); diff --git a/epicardium/epicardium.h b/epicardium/epicardium.h index ca295376..3a2fea1a 100644 --- a/epicardium/epicardium.h +++ b/epicardium/epicardium.h @@ -2332,7 +2332,7 @@ API(API_BLE_GET_SCAN_REPORT, int epic_ble_get_scan_report(struct epic_scan_repor * :return: `0` on success, `1` if the report is queued or a negative value if an error occured. Possible * errors: * - * - ``-EIO``: There is no host device connected + * - ``-EIO``: There is no host device connected or BLE HID is not enabled. * - ``-EAGAIN``: There is no space in the queue available. Try again later. * - ``-EINVAL``: Either the report_id is out of range or the data is too long. * -- GitLab