diff options
author | Joel Spadin <joelspadin@gmail.com> | 2020-10-11 14:58:24 -0500 |
---|---|---|
committer | Joel Spadin <joelspadin@gmail.com> | 2020-10-11 17:04:34 -0500 |
commit | 7798c974f697afb43d13cf8692802caf87210b02 (patch) | |
tree | 4114b939376e9785ea48b8320538b37e1aedd8c7 /app/src/hog.c | |
parent | ba73e5d4ac295cc67e03fca9f80030022b8f529c (diff) |
fix: don't leak bt_conn refs
bt_conn_lookup_addr_le() gives us a new reference that must be released
with bt_conn_unref()
Diffstat (limited to 'app/src/hog.c')
-rw-r--r-- | app/src/hog.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/app/src/hog.c b/app/src/hog.c index 11349ac..bcd652d 100644 --- a/app/src/hog.c +++ b/app/src/hog.c @@ -164,8 +164,10 @@ int zmk_hog_send_keypad_report(struct zmk_hid_keypad_report_body *report) { LOG_DBG("Sending to NULL? %s", conn == NULL ? "yes" : "no"); - return bt_gatt_notify(conn, &hog_svc.attrs[5], report, - sizeof(struct zmk_hid_keypad_report_body)); + int err = + bt_gatt_notify(conn, &hog_svc.attrs[5], report, sizeof(struct zmk_hid_keypad_report_body)); + bt_conn_unref(conn); + return err; }; int zmk_hog_send_consumer_report(struct zmk_hid_consumer_report_body *report) { @@ -174,6 +176,8 @@ int zmk_hog_send_consumer_report(struct zmk_hid_consumer_report_body *report) { return -ENOTCONN; } - return bt_gatt_notify(conn, &hog_svc.attrs[10], report, - sizeof(struct zmk_hid_consumer_report_body)); + int err = bt_gatt_notify(conn, &hog_svc.attrs[10], report, + sizeof(struct zmk_hid_consumer_report_body)); + bt_conn_unref(conn); + return err; }; |