Bluetooth: Mesh: Check return value of bt_conn_get_info

Coverity-CID: 323094
Fixes #65366

Coverity-CID: 323081
Fixes #65370

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
This commit is contained in:
Pavel Vasilyev 2023-11-17 09:40:25 +01:00 committed by Carles Cufí
commit b15611eb28
3 changed files with 21 additions and 16 deletions

View file

@ -176,8 +176,8 @@ static void gatt_connected(struct bt_conn *conn, uint8_t conn_err)
struct bt_conn_info info; struct bt_conn_info info;
int err; int err;
bt_conn_get_info(conn, &info); err = bt_conn_get_info(conn, &info);
if (info.role != BT_CONN_ROLE_CENTRAL || if (err || info.role != BT_CONN_ROLE_CENTRAL ||
!server->gatt) { !server->gatt) {
return; return;
} }
@ -214,9 +214,10 @@ static void gatt_disconnected(struct bt_conn *conn, uint8_t reason)
{ {
struct bt_conn_info info; struct bt_conn_info info;
struct bt_mesh_gatt_server *server = get_server(conn); struct bt_mesh_gatt_server *server = get_server(conn);
int err;
bt_conn_get_info(conn, &info); err = bt_conn_get_info(conn, &info);
if (info.role != BT_CONN_ROLE_CENTRAL || if (err || info.role != BT_CONN_ROLE_CENTRAL ||
!server->gatt) { !server->gatt) {
return; return;
} }

View file

@ -94,27 +94,29 @@ static ssize_t gatt_recv(struct bt_conn *conn,
return bt_mesh_proxy_msg_recv(conn, buf, len); return bt_mesh_proxy_msg_recv(conn, buf, len);
} }
static void gatt_connected(struct bt_conn *conn, uint8_t err) static void gatt_connected(struct bt_conn *conn, uint8_t conn_err)
{ {
struct bt_conn_info info; struct bt_conn_info info;
int err;
bt_conn_get_info(conn, &info); err = bt_conn_get_info(conn, &info);
if (info.role != BT_CONN_ROLE_PERIPHERAL || !service_registered || if (err || info.role != BT_CONN_ROLE_PERIPHERAL || !service_registered ||
bt_mesh_is_provisioned() || info.id != BT_ID_DEFAULT || cli) { bt_mesh_is_provisioned() || info.id != BT_ID_DEFAULT || cli) {
return; return;
} }
cli = bt_mesh_proxy_role_setup(conn, gatt_send, proxy_msg_recv); cli = bt_mesh_proxy_role_setup(conn, gatt_send, proxy_msg_recv);
LOG_DBG("conn %p err 0x%02x", (void *)conn, err); LOG_DBG("conn %p err 0x%02x", (void *)conn, conn_err);
} }
static void gatt_disconnected(struct bt_conn *conn, uint8_t reason) static void gatt_disconnected(struct bt_conn *conn, uint8_t reason)
{ {
struct bt_conn_info info; struct bt_conn_info info;
int err;
bt_conn_get_info(conn, &info); err = bt_conn_get_info(conn, &info);
if (info.role != BT_CONN_ROLE_PERIPHERAL || !service_registered || if (err || info.role != BT_CONN_ROLE_PERIPHERAL || !service_registered ||
info.id != BT_ID_DEFAULT || !cli || cli->conn != conn) { info.id != BT_ID_DEFAULT || !cli || cli->conn != conn) {
return; return;
} }

View file

@ -1057,18 +1057,19 @@ static void solicitation_reset(struct bt_mesh_subnet *sub)
#endif #endif
} }
static void gatt_connected(struct bt_conn *conn, uint8_t err) static void gatt_connected(struct bt_conn *conn, uint8_t conn_err)
{ {
struct bt_mesh_proxy_client *client; struct bt_mesh_proxy_client *client;
struct bt_conn_info info; struct bt_conn_info info;
int err;
bt_conn_get_info(conn, &info); err = bt_conn_get_info(conn, &info);
if (info.role != BT_CONN_ROLE_PERIPHERAL || !service_registered || if (err || info.role != BT_CONN_ROLE_PERIPHERAL || !service_registered ||
info.id != BT_ID_DEFAULT) { info.id != BT_ID_DEFAULT) {
return; return;
} }
LOG_DBG("conn %p err 0x%02x", (void *)conn, err); LOG_DBG("conn %p err 0x%02x", (void *)conn, conn_err);
client = find_client(conn); client = find_client(conn);
@ -1107,9 +1108,10 @@ static void gatt_disconnected(struct bt_conn *conn, uint8_t reason)
{ {
struct bt_conn_info info; struct bt_conn_info info;
struct bt_mesh_proxy_client *client; struct bt_mesh_proxy_client *client;
int err;
bt_conn_get_info(conn, &info); err = bt_conn_get_info(conn, &info);
if (info.role != BT_CONN_ROLE_PERIPHERAL || info.id != BT_ID_DEFAULT) { if (err || info.role != BT_CONN_ROLE_PERIPHERAL || info.id != BT_ID_DEFAULT) {
return; return;
} }