Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

host/audio/pacs: fix possible NULL dereference #1757

Merged
merged 1 commit into from
Apr 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions nimble/host/audio/services/pacs/src/ble_audio_svc_pacs.c
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,9 @@ ble_svc_audio_pacs_avail_audio_ctx_read_access(uint16_t conn_handle,
uint8_t *buf;

avail_ctx = ble_svc_audio_pacs_find_avail_ctx(conn_handle);
if (!avail_ctx) {
return BLE_HS_ENOENT;
}

buf = os_mbuf_extend(ctxt->om, 4);
if (buf == NULL) {
Expand Down Expand Up @@ -400,6 +403,9 @@ ble_svc_audio_pacs_avail_contexts_set(uint16_t conn_handle,
uint16_t source_contexts)
{
struct available_ctx *avail_ctx = ble_svc_audio_pacs_find_avail_ctx(conn_handle);
if (!avail_ctx) {
return BLE_HS_ENOENT;
}

avail_ctx->ble_svc_audio_pacs_avail_sink_contexts = sink_contexts;
avail_ctx->ble_svc_audio_pacs_avail_source_contexts = source_contexts;
Expand Down Expand Up @@ -441,10 +447,18 @@ ble_pacs_gap_event(struct ble_gap_event *event, void *arg)
break;
}
avail_ctx = ble_svc_audio_pacs_find_avail_ctx(BLE_HS_CONN_HANDLE_NONE);
if (!avail_ctx) {
return BLE_HS_ENOENT;
}

avail_ctx->conn_handle = event->connect.conn_handle;
break;
case BLE_GAP_EVENT_DISCONNECT:
avail_ctx = ble_svc_audio_pacs_find_avail_ctx(event->disconnect.conn.conn_handle);
if (!avail_ctx) {
return BLE_HS_ENOENT;
}

if (avail_ctx >= 0) {
avail_ctx->conn_handle = BLE_HS_CONN_HANDLE_NONE;
}
Expand Down
Loading