Skip to content

Commit 33b0c0d

Browse files
finikorgnashif
authored andcommitted
bluetooth: ias: Fix dereferencing before NULL check
It does make sense to dereference after NULL check. Signed-off-by: Andrei Emeltchenko <[email protected]>
1 parent 4d2914c commit 33b0c0d

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

subsys/bluetooth/services/ias/ias_client.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ static uint8_t bt_ias_alert_lvl_disc_cb(struct bt_conn *conn,
9696
const struct bt_gatt_attr *attr,
9797
struct bt_gatt_discover_params *discover)
9898
{
99-
const struct bt_gatt_chrc *chrc = (struct bt_gatt_chrc *)attr->user_data;
99+
const struct bt_gatt_chrc *chrc;
100100

101101
atomic_clear_bit(client_by_conn(conn)->flags, IAS_DISCOVER_IN_PROGRESS);
102102

@@ -106,6 +106,8 @@ static uint8_t bt_ias_alert_lvl_disc_cb(struct bt_conn *conn,
106106
return BT_GATT_ITER_STOP;
107107
}
108108

109+
chrc = (struct bt_gatt_chrc *)attr->user_data;
110+
109111
client_by_conn(conn)->alert_level_handle = chrc->value_handle;
110112
discover_complete(conn, 0);
111113

0 commit comments

Comments
 (0)