Skip to content

Commit c718d9b

Browse files
committed
fix(data_model): silence spurious "Cluster cannot be NULL" error during dynamic endpoint init
When using the esp_matter data model (CONFIG_ESP_MATTER_ENABLE_DATA_MODEL=y), attribute::get(endpoint_id, cluster_id, attribute_id) is called during endpoint registration via emberAfExternalAttributeReadCallback. If the cluster doesn't exist on the endpoint, the lookup returns NULL, which is then passed to the two-argument get(cluster_t*, attribute_id) overload that logs at error level. Add a NULL guard in the three-argument overload to return nullptr early, consistent with how command::get(endpoint_id, cluster_id, command_id) already handles this case. Fixes #1692
1 parent 7a3c60a commit c718d9b

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

components/esp_matter/data_model/esp_matter_data_model.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ static void report_parts_list_change_internal(endpoint_t *endpoint)
222222
parent_endpoint_id = endpoint::get_parent_endpoint_id(endpoint::get(parent_endpoint_id));
223223
}
224224
MatterReportingAttributeChangeCallback(/* endpoint = */ 0, chip::app::Clusters::Descriptor::Id,
225-
chip::app::Clusters::Descriptor::Attributes::PartsList::Id);
225+
chip::app::Clusters::Descriptor::Attributes::PartsList::Id);
226226
}
227227

228228
esp_err_t disable(endpoint_t *endpoint)
@@ -696,6 +696,9 @@ attribute_t *get(cluster_t *cluster, uint32_t attribute_id)
696696
attribute_t *get(uint16_t endpoint_id, uint32_t cluster_id, uint32_t attribute_id)
697697
{
698698
cluster_t *cluster = cluster::get(endpoint_id, cluster_id);
699+
if (!cluster) {
700+
return nullptr;
701+
}
699702
return get(cluster, attribute_id);
700703
}
701704

0 commit comments

Comments
 (0)