diff mbox series

[BlueZ,v1] shared/bap: move checks for NULL before dereferencing

Message ID 20240703092322.16659-1-r.smirnov@omp.ru
State New
Headers show
Series [BlueZ,v1] shared/bap: move checks for NULL before dereferencing | expand

Commit Message

Roman Smirnov July 3, 2024, 9:23 a.m. UTC
It is necessary to prevent dereferencing of NULL pointers.

Found with the SVACE static analysis tool.
---
 src/shared/bap.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

Comments

patchwork-bot+bluetooth@kernel.org July 3, 2024, 3:10 p.m. UTC | #1
Hello:

This patch was applied to bluetooth/bluez.git (master)
by Luiz Augusto von Dentz <luiz.von.dentz@intel.com>:

On Wed, 3 Jul 2024 12:23:22 +0300 you wrote:
> It is necessary to prevent dereferencing of NULL pointers.
> 
> Found with the SVACE static analysis tool.
> ---
>  src/shared/bap.c | 12 +++++++-----
>  1 file changed, 7 insertions(+), 5 deletions(-)

Here is the summary with links:
  - [BlueZ,v1] shared/bap: move checks for NULL before dereferencing
    https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=1b961b9e15c6

You are awesome, thank you!
diff mbox series

Patch

diff --git a/src/shared/bap.c b/src/shared/bap.c
index ec54da341..defeeb635 100644
--- a/src/shared/bap.c
+++ b/src/shared/bap.c
@@ -1870,11 +1870,11 @@  static unsigned int bap_ucast_disable(struct bt_bap_stream *stream,
 
 static uint8_t stream_stop(struct bt_bap_stream *stream, struct iovec *rsp)
 {
-	DBG(stream->bap, "stream %p", stream);
-
 	if (!stream)
 		return 0;
 
+	DBG(stream->bap, "stream %p", stream);
+
 	ascs_ase_rsp_success(rsp, stream->ep->id);
 
 	stream_set_state(stream, BT_BAP_STREAM_STATE_QOS);
@@ -2751,12 +2751,12 @@  static uint8_t ascs_start(struct bt_ascs *ascs, struct bt_bap *bap,
 
 static uint8_t stream_disable(struct bt_bap_stream *stream, struct iovec *rsp)
 {
-	DBG(stream->bap, "stream %p", stream);
-
 	if (!stream || stream->ep->state == BT_BAP_STREAM_STATE_QOS ||
 			stream->ep->state == BT_BAP_STREAM_STATE_IDLE)
 		return 0;
 
+	DBG(stream->bap, "stream %p", stream);
+
 	ascs_ase_rsp_success(rsp, stream->ep->id);
 
 	/* Sink can autonomously transit to QOS while source needs to go to
@@ -5830,11 +5830,13 @@  int bt_bap_stream_cancel(struct bt_bap_stream *stream, unsigned int id)
 int bt_bap_stream_io_link(struct bt_bap_stream *stream,
 				struct bt_bap_stream *link)
 {
-	struct bt_bap *bap = stream->bap;
+	struct bt_bap *bap;
 
 	if (!stream || !link || stream == link)
 		return -EINVAL;
 
+	bap = stream->bap;
+
 	if (stream->link || link->link)
 		return -EALREADY;