bap: Fix not setting stream to NULL
authorLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
Mon, 23 Jan 2023 21:27:14 +0000 (13:27 -0800)
committerAyush Garg <ayush.garg@samsung.com>
Fri, 5 Jan 2024 10:11:34 +0000 (15:41 +0530)
commit0696e0c92da395fcfea9c175f5356b430b2404ad
treedb14ecc7c7b624fee06bca82978c437419c5f1e8
parent539ddcde4675992eb956277da0eb966654a360b6
bap: Fix not setting stream to NULL

If the stream state is idle the ep->stream shall be set to NULL
otherwise it may be reused causing the following trace:

==32623==ERROR: AddressSanitizer: heap-use-after-free on address ...
 READ of size 8 at 0x60b000103550 thread T0
    #0 0x7bf7b7 in bap_stream_valid src/shared/bap.c:4065
    #1 0x7bf981 in bt_bap_stream_config src/shared/bap.c:4082
    #2 0x51a7c8 in bap_config profiles/audio/bap.c:584
    #3 0x71b907 in queue_foreach src/shared/queue.c:207
    #4 0x51b61f in select_cb profiles/audio/bap.c:626
    #5 0x4691ed in pac_select_cb profiles/audio/media.c:884
    #6 0x4657ea in endpoint_reply profiles/audio/media.c:369

Fixes: https://github.com/bluez/bluez/issues/457#issuecomment-1399232486
profiles/audio/bap.c