From: Luiz Augusto von Dentz <luiz.von.dentz@xxxxxxxxx> If bt_uhid_new fails there is likely a problem with uHID module or bluetoothd don't have previleges to access /dev/uhid. --- profiles/input/hog-lib.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/profiles/input/hog-lib.c b/profiles/input/hog-lib.c index 729603702e5f..22599f71a394 100644 --- a/profiles/input/hog-lib.c +++ b/profiles/input/hog-lib.c @@ -1421,23 +1421,29 @@ static struct bt_hog *hog_new(int fd, const char *name, uint16_t vendor, uint8_t type, struct gatt_db_attribute *attr) { + struct bt_uhid *uhid; struct bt_hog *hog; + if (fd < 0) + uhid = bt_uhid_new_default(); + else + uhid = bt_uhid_new(fd); + + if (!uhid) { + DBG("Unable to create UHID"); + return NULL; + } + hog = g_try_new0(struct bt_hog, 1); if (!hog) return NULL; hog->gatt_op = queue_new(); hog->bas = queue_new(); - - if (fd < 0) - hog->uhid = bt_uhid_new_default(); - else - hog->uhid = bt_uhid_new(fd); - hog->uhid_fd = fd; + hog->uhid = uhid; - if (!hog->gatt_op || !hog->bas || !hog->uhid) { + if (!hog->gatt_op || !hog->bas) { hog_free(hog); return NULL; } -- 2.46.0