diff --git a/subsys/bluetooth/host/gatt.c b/subsys/bluetooth/host/gatt.c index 08f00d50d24..b0902baea1c 100644 --- a/subsys/bluetooth/host/gatt.c +++ b/subsys/bluetooth/host/gatt.c @@ -2130,10 +2130,6 @@ uint16_t bt_gatt_get_mtu(struct bt_conn *conn) uint8_t bt_gatt_check_perm(struct bt_conn *conn, const struct bt_gatt_attr *attr, uint8_t mask) { - if (IS_ENABLED(CONFIG_BT_CONN_DISABLE_SECURITY)) { - return 0; - } - if ((mask & BT_GATT_PERM_READ) && (!(attr->perm & BT_GATT_PERM_READ_MASK) || !attr->read)) { return BT_ATT_ERR_READ_NOT_PERMITTED; @@ -2144,6 +2140,10 @@ uint8_t bt_gatt_check_perm(struct bt_conn *conn, const struct bt_gatt_attr *attr return BT_ATT_ERR_WRITE_NOT_PERMITTED; } + if (IS_ENABLED(CONFIG_BT_CONN_DISABLE_SECURITY)) { + return 0; + } + mask &= attr->perm; if (mask & BT_GATT_PERM_AUTHEN_MASK) { if (bt_conn_get_security(conn) < BT_SECURITY_L3) {