diff mbox series

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

Message ID 20240703092322.16659-1-r.smirnov@omp.ru (mailing list archive)
State Accepted
Commit 1b961b9e15c6de1cf96de29ed16d0008b9c64c5d
Headers show
Series [BlueZ,v1] shared/bap: move checks for NULL before dereferencing | expand

Checks

Context Check Description
tedd_an/pre-ci_am success Success
tedd_an/CheckPatch success CheckPatch PASS
tedd_an/GitLint success Gitlint PASS
tedd_an/BuildEll success Build ELL PASS
tedd_an/BluezMake success Bluez Make PASS
tedd_an/MakeCheck success Bluez Make Check PASS
tedd_an/MakeDistcheck success Make Distcheck PASS
tedd_an/CheckValgrind success Check Valgrind PASS
tedd_an/CheckSmatch warning CheckSparse WARNING src/shared/bap.c:286:25: warning: array of flexible structuressrc/shared/bap.c: note: in included file:./src/shared/ascs.h:88:25: warning: array of flexible structuressrc/shared/bap.c:286:25: warning: array of flexible structuressrc/shared/bap.c: note: in included file:./src/shared/ascs.h:88:25: warning: array of flexible structuressrc/shared/bap.c:286:25: warning: array of flexible structuressrc/shared/bap.c: note: in included file:./src/shared/ascs.h:88:25: warning: array of flexible structures
tedd_an/bluezmakeextell success Make External ELL PASS
tedd_an/IncrementalBuild success Incremental Build PASS
tedd_an/ScanBuild success Scan Build PASS

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

bluez.test.bot@gmail.com July 3, 2024, 10:57 a.m. UTC | #1
This is automated email and please do not reply to this email!

Dear submitter,

Thank you for submitting the patches to the linux bluetooth mailing list.
This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=867905

---Test result---

Test Summary:
CheckPatch                    PASS      0.27 seconds
GitLint                       PASS      0.19 seconds
BuildEll                      PASS      24.43 seconds
BluezMake                     PASS      1604.72 seconds
MakeCheck                     PASS      12.97 seconds
MakeDistcheck                 PASS      175.01 seconds
CheckValgrind                 PASS      248.49 seconds
CheckSmatch                   WARNING   350.09 seconds
bluezmakeextell               PASS      118.20 seconds
IncrementalBuild              PASS      1354.84 seconds
ScanBuild                     PASS      972.29 seconds

Details
##############################
Test: CheckSmatch - WARNING
Desc: Run smatch tool with source
Output:
src/shared/bap.c:286:25: warning: array of flexible structuressrc/shared/bap.c: note: in included file:./src/shared/ascs.h:88:25: warning: array of flexible structuressrc/shared/bap.c:286:25: warning: array of flexible structuressrc/shared/bap.c: note: in included file:./src/shared/ascs.h:88:25: warning: array of flexible structuressrc/shared/bap.c:286:25: warning: array of flexible structuressrc/shared/bap.c: note: in included file:./src/shared/ascs.h:88:25: warning: array of flexible structures


---
Regards,
Linux Bluetooth
patchwork-bot+bluetooth@kernel.org July 3, 2024, 3:10 p.m. UTC | #2
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;