Bluetooth: audio: has: Fix coverity issues
This fixes issues discovered by coverity check.
Fixes: #65325
Fixes: #65326
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
diff --git a/subsys/bluetooth/audio/has.c b/subsys/bluetooth/audio/has.c
index 6013cad..26f719b 100644
--- a/subsys/bluetooth/audio/has.c
+++ b/subsys/bluetooth/audio/has.c
@@ -205,6 +205,8 @@
static struct client_context *context_find(const bt_addr_le_t *addr)
{
+ __ASSERT_NO_MSG(addr != NULL);
+
for (size_t i = 0; i < ARRAY_SIZE(contexts); i++) {
if (bt_addr_le_eq(&contexts[i].addr, addr)) {
return &contexts[i];
@@ -218,6 +220,8 @@
{
struct client_context *context;
+ __ASSERT_NO_MSG(addr != NULL);
+
/* Free contexts has BT_ADDR_LE_ANY as the address */
context = context_find(BT_ADDR_LE_ANY);
if (context == NULL) {
@@ -262,6 +266,7 @@
{
struct bt_conn_info info = { 0 };
struct has_client *client = NULL;
+ int err;
for (size_t i = 0; i < ARRAY_SIZE(has_client_list); i++) {
if (conn == has_client_list[i].conn) {
@@ -284,7 +289,12 @@
k_work_init_delayable(&client->notify_work, notify_work_handler);
#endif /* CONFIG_BT_HAS_PRESET_SUPPORT || CONFIG_BT_HAS_FEATURES_NOTIFIABLE */
- bt_conn_get_info(conn, &info);
+ err = bt_conn_get_info(conn, &info);
+ if (err != 0) {
+ LOG_DBG("Could not get conn info: %d", err);
+
+ return NULL;
+ }
client->context = context_find(info.le.dst);
if (client->context == NULL) {