From 345c3f17eb4b69f2ab6f6a3082bdba7ac4dbe517 Mon Sep 17 00:00:00 2001 From: Make Shi Date: Wed, 11 Dec 2024 13:26:14 +0800 Subject: [PATCH] Bluetooth: Shell: BR: Add NULL pointer check for result->resp_buf In case the peer device has NO SDP record, the result is valid, but the result->resp_buf is NULL, it would introduce a hardfault. Therefore, also add a NULL pointer check for result->resp_buf. Signed-off-by: Make Shi --- subsys/bluetooth/host/classic/shell/bredr.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/subsys/bluetooth/host/classic/shell/bredr.c b/subsys/bluetooth/host/classic/shell/bredr.c index 4a847a42ca3..b59dee96fb7 100644 --- a/subsys/bluetooth/host/classic/shell/bredr.c +++ b/subsys/bluetooth/host/classic/shell/bredr.c @@ -380,7 +380,7 @@ static uint8_t sdp_hfp_ag_user(struct bt_conn *conn, conn_addr_str(conn, addr, sizeof(addr)); - if (result) { + if (result && result->resp_buf) { shell_print(ctx_shell, "SDP HFPAG data@%p (len %u) hint %u from" " remote %s", result->resp_buf, result->resp_buf->len, result->next_record_hint, @@ -440,7 +440,7 @@ static uint8_t sdp_a2src_user(struct bt_conn *conn, conn_addr_str(conn, addr, sizeof(addr)); - if (result) { + if (result && result->resp_buf) { shell_print(ctx_shell, "SDP A2SRC data@%p (len %u) hint %u from" " remote %s", result->resp_buf, result->resp_buf->len, result->next_record_hint,