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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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(-)

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;
 
-- 
2.43.0





[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux