Diff between 1cc3cf08c4934e3c4dc1413e11ac84ac53ea28cf and d5c68dbed1eeffd62f55030bdc383c7a684daf69

Changed Files

File Additions Deletions Status
profiles/input/hog-lib.c +13 -7 modified

Full Patch

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
@@ -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;
 	}