Commit 5969c3b
Bluetooth: Host: Fix resource leak in bt_gatt_unsubscribe
There are two simmilar functions for unsubscribing from GATT handles.
- `gatt_sub_remove`, which is called on disconnect for every
subscription will free the `subscriptions` entry when the entry
represents no subscriptions.
- `bt_gatt_unsubscribe`, called by the application, which forgets to
free the `subscriptions` entry.
If all subscriptions grouped in a `subscriptions` entry are removed
using `bt_gatt_unsubscribe` before disconnect, there are no
subscriptions left to call `gatt_sub_remove` on. The `subscriptions`
entry is then never freed.
The above results in a resource leak of a `subscriptions` entry.
This fix makes explicit and enforces the invariant that there should not
be entries in `subscriptions` with an empty subscription list.
Fixes #38688
Signed-off-by: Aleksander Wasaznik <[email protected]>1 parent 6db7778 commit 5969c3b
1 file changed
+24
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
70 | 70 | | |
71 | 71 | | |
72 | 72 | | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
73 | 78 | | |
74 | 79 | | |
75 | 80 | | |
| |||
2699 | 2704 | | |
2700 | 2705 | | |
2701 | 2706 | | |
| 2707 | + | |
| 2708 | + | |
| 2709 | + | |
| 2710 | + | |
| 2711 | + | |
| 2712 | + | |
| 2713 | + | |
| 2714 | + | |
| 2715 | + | |
| 2716 | + | |
| 2717 | + | |
| 2718 | + | |
| 2719 | + | |
2702 | 2720 | | |
2703 | 2721 | | |
2704 | 2722 | | |
| |||
2710 | 2728 | | |
2711 | 2729 | | |
2712 | 2730 | | |
2713 | | - | |
2714 | | - | |
2715 | | - | |
| 2731 | + | |
| 2732 | + | |
2716 | 2733 | | |
2717 | 2734 | | |
2718 | 2735 | | |
| |||
4597 | 4614 | | |
4598 | 4615 | | |
4599 | 4616 | | |
| 4617 | + | |
| 4618 | + | |
| 4619 | + | |
| 4620 | + | |
4600 | 4621 | | |
4601 | 4622 | | |
4602 | 4623 | | |
| |||
0 commit comments