Skip to content

Commit a738b26

Browse files
Thalleykartben
authored andcommitted
Bluetooth: BAP: Add NULL check in bt_bap_stream_detach
If stream->ep is NULL, which is really shouldn't be, then we should not attempt to dereference it. Add simple NULL check to ensure behavior, and make Sonarcloud happy. Signed-off-by: Emil Gydesen <[email protected]>
1 parent 9209390 commit a738b26

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

subsys/bluetooth/audio/bap_stream.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -531,8 +531,11 @@ void bt_bap_stream_detach(struct bt_bap_stream *stream)
531531
stream->conn = NULL;
532532
}
533533
stream->codec_cfg = NULL;
534-
stream->ep->stream = NULL;
535-
stream->ep = NULL;
534+
535+
if (stream->ep != NULL) {
536+
stream->ep->stream = NULL;
537+
stream->ep = NULL;
538+
}
536539

537540
if (!is_broadcast) {
538541
const int err = bt_bap_stream_disconnect(stream);

0 commit comments

Comments
 (0)