Diff between 1721258a7d95b8f294d8875ff030eca9b24a2e60 and eeaa5a1afb181fe0595c7395f3316d683fce86aa

Changed Files

File Additions Deletions Status
profiles/input/hog.c +9 -1 modified

Full Patch

diff --git a/profiles/input/hog.c b/profiles/input/hog.c
index 4dba83f..a934c62 100644
--- a/profiles/input/hog.c
+++ b/profiles/input/hog.c
@@ -107,8 +107,13 @@ static struct hog_device *hog_device_new(struct btd_device *device,
 							product, version);
 
 	dev = new0(struct hog_device, 1);
-	dev->device = btd_device_ref(device);
 	dev->hog = bt_hog_new_default(name, vendor, product, version, prim);
+	if (!dev->hog) {
+		free(dev);
+		return NULL;
+	}
+
+	dev->device = btd_device_ref(device);
 
 	/*
 	 * TODO: Remove attio callback and use .accept once using
@@ -189,6 +194,9 @@ static int hog_probe(struct btd_service *service)
 			continue;
 
 		dev = hog_device_new(device, prim);
+		if (!dev)
+			break;
+
 		btd_service_set_user_data(service, dev);
 		return 0;
 	}