diff --git a/profiles/input/hog-lib.c b/profiles/input/hog-lib.c
index 7296037..22599f7 100644
--- a/profiles/input/hog-lib.c
+++ b/profiles/input/hog-lib.c
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;
}