linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH BlueZ v1] shared/bap: prevent dereferencing of NULL pointers in ascs_ase_read()
@ 2024-07-03  9:03 Roman Smirnov
  2024-07-03 10:40 ` [BlueZ,v1] " bluez.test.bot
  2024-07-03 15:10 ` [PATCH BlueZ v1] " patchwork-bot+bluetooth
  0 siblings, 2 replies; 3+ messages in thread
From: Roman Smirnov @ 2024-07-03  9:03 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Roman Smirnov

If the user_data argument is NULL, a NULL pointer will
be dereferenced. It is necessary to prevent this case.

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

diff --git a/src/shared/bap.c b/src/shared/bap.c
index ec54da341..cb5ea9e84 100644
--- a/src/shared/bap.c
+++ b/src/shared/bap.c
@@ -805,12 +805,17 @@ static void ascs_ase_read(struct gatt_db_attribute *attrib,
 				void *user_data)
 {
 	struct bt_ase *ase = user_data;
-	struct bt_bap *bap = bap_get_session(att, ase->ascs->bdb->db);
-	struct bt_bap_endpoint *ep = bap_get_endpoint(bap->local_eps,
-							bap->ldb, attrib);
+	struct bt_bap *bap = NULL;
+	struct bt_bap_endpoint *ep = NULL;
 	struct bt_ascs_ase_status rsp;
 
-	if (!ase || !bap || !ep) {
+	if (ase)
+		bap = bap_get_session(att, ase->ascs->bdb->db);
+
+	if (bap)
+		ep = bap_get_endpoint(bap->local_eps, bap->ldb, attrib);
+
+	if (!ep) {
 		gatt_db_attribute_read_result(attrib, id, BT_ATT_ERROR_UNLIKELY,
 								NULL, 0);
 		return;
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* RE: [BlueZ,v1] shared/bap: prevent dereferencing of NULL pointers in ascs_ase_read()
  2024-07-03  9:03 [PATCH BlueZ v1] shared/bap: prevent dereferencing of NULL pointers in ascs_ase_read() Roman Smirnov
@ 2024-07-03 10:40 ` bluez.test.bot
  2024-07-03 15:10 ` [PATCH BlueZ v1] " patchwork-bot+bluetooth
  1 sibling, 0 replies; 3+ messages in thread
From: bluez.test.bot @ 2024-07-03 10:40 UTC (permalink / raw)
  To: linux-bluetooth, r.smirnov

[-- Attachment #1: Type: text/plain, Size: 1559 bytes --]

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=867893

---Test result---

Test Summary:
CheckPatch                    PASS      1.57 seconds
GitLint                       PASS      0.49 seconds
BuildEll                      PASS      24.47 seconds
BluezMake                     PASS      1655.50 seconds
MakeCheck                     PASS      12.76 seconds
MakeDistcheck                 PASS      177.44 seconds
CheckValgrind                 PASS      251.55 seconds
CheckSmatch                   WARNING   353.10 seconds
bluezmakeextell               PASS      119.45 seconds
IncrementalBuild              PASS      1439.56 seconds
ScanBuild                     PASS      986.28 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


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH BlueZ v1] shared/bap: prevent dereferencing of NULL pointers in ascs_ase_read()
  2024-07-03  9:03 [PATCH BlueZ v1] shared/bap: prevent dereferencing of NULL pointers in ascs_ase_read() Roman Smirnov
  2024-07-03 10:40 ` [BlueZ,v1] " bluez.test.bot
@ 2024-07-03 15:10 ` patchwork-bot+bluetooth
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+bluetooth @ 2024-07-03 15:10 UTC (permalink / raw)
  To: Roman Smirnov; +Cc: linux-bluetooth

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:03:05 +0300 you wrote:
> If the user_data argument is NULL, a NULL pointer will
> be dereferenced. It is necessary to prevent this case.
> 
> Found with the SVACE static analysis tool.
> ---
>  src/shared/bap.c | 13 +++++++++----
>  1 file changed, 9 insertions(+), 4 deletions(-)

Here is the summary with links:
  - [BlueZ,v1] shared/bap: prevent dereferencing of NULL pointers in ascs_ase_read()
    https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=8a22c17bc996

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-07-03 15:10 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-03  9:03 [PATCH BlueZ v1] shared/bap: prevent dereferencing of NULL pointers in ascs_ase_read() Roman Smirnov
2024-07-03 10:40 ` [BlueZ,v1] " bluez.test.bot
2024-07-03 15:10 ` [PATCH BlueZ v1] " patchwork-bot+bluetooth

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).