samples: Bluetooth: Broadcast Audio Source: Fix potential memory leak
In error cases, where send_data() returns early, the allocated net_buf is not free'd, causing a memory leak affecting the net_buf pool. Fix this by freeing the allocated net_buf before returning early from send_data(). Signed-off-by: Sean Farrelly <sean.farrelly@outlook.com>
This commit is contained in:
parent
6bb5076a21
commit
9e28e9e564
1 changed files with 2 additions and 0 deletions
|
@ -171,6 +171,7 @@ static void send_data(struct broadcast_source_stream *source_stream)
|
|||
|
||||
if (source_stream->lc3_encoder == NULL) {
|
||||
printk("LC3 encoder not setup, cannot encode data.\n");
|
||||
net_buf_unref(buf);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -190,6 +191,7 @@ static void send_data(struct broadcast_source_stream *source_stream)
|
|||
send_pcm_data, 1, octets_per_frame, lc3_encoded_buffer);
|
||||
if (ret == -1) {
|
||||
printk("LC3 encoder failed - wrong parameters?: %d", ret);
|
||||
net_buf_unref(buf);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue