summaryrefslogtreecommitdiff
path: root/profiles/input
diff options
context:
space:
mode:
authorStéphane Cerveau <scerveau@collabora.com>2020-04-20 20:40:29 +0200
committerLuiz Augusto von Dentz <luiz.von.dentz@intel.com>2020-04-20 14:05:48 -0700
commit71b5dbc7049e718f36d1ff0a4332cb79f2ccb654 (patch)
tree6f38f496f05c64df06ea1ec2f7cf95a470387a91 /profiles/input
parent86fbb15cb7ff82e02674713013141a3bd1ead12d (diff)
downloadbluez-71b5dbc7049e718f36d1ff0a4332cb79f2ccb654.tar.gz
add hog ref before adding to instances
To avoid a double hog free, need to add a ref when adding the hog to the slist. This bug has been reproduced with gamepad-8718 which was connecting/disconnecting frantically. Fix also a typo in the method hog_attach_instance
Diffstat (limited to 'profiles/input')
-rw-r--r--profiles/input/hog-lib.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/profiles/input/hog-lib.c b/profiles/input/hog-lib.c
index 9c5c814a7..8fb0283ca 100644
--- a/profiles/input/hog-lib.c
+++ b/profiles/input/hog-lib.c
@@ -1357,7 +1357,7 @@ static struct bt_hog *hog_new(int fd, const char *name, uint16_t vendor,
return hog;
}
-static void hog_attach_instace(struct bt_hog *hog,
+static void hog_attach_instance(struct bt_hog *hog,
struct gatt_db_attribute *attr)
{
struct bt_hog *instance;
@@ -1373,14 +1373,14 @@ static void hog_attach_instace(struct bt_hog *hog,
if (!instance)
return;
- hog->instances = g_slist_append(hog->instances, instance);
+ hog->instances = g_slist_append(hog->instances, bt_hog_ref(instance));
}
static void foreach_hog_service(struct gatt_db_attribute *attr, void *user_data)
{
struct bt_hog *hog = user_data;
- hog_attach_instace(hog, attr);
+ hog_attach_instance(hog, attr);
}
static void dis_notify(uint8_t source, uint16_t vendor, uint16_t product,