add hog ref before adding to instances
PATCH 1/1 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
--- profiles/input/hog-lib.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
profiles/input/hog-lib.c +3 -3
@@ -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,
Signature · 1 line
2.17.1
Hi Stéphane,
Quoted 43 lines · Stéphane Cerveau
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--- profiles/input/hog-lib.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)profiles/input/hog-lib.c +3
-4@@ -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, --
Quoted 1 line
2.17.1
Applied, thanks.
Signature · 1 line
Luiz Augusto von Dentz