components/esp_matter:Add null check for config before pointer dereference

This commit is contained in:
mahesh
2025-10-21 12:28:54 +05:30
parent d556f67bb4
commit e24cab6242
@@ -221,7 +221,7 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags)
VerifyOrReturnValue(cluster, NULL, ESP_LOGE(TAG, "Could not create cluster. cluster_id: 0x%08" PRIX32, Actions::Id));
if (flags & CLUSTER_FLAG_SERVER) {
if (config -> delegate != nullptr) {
if (config && config->delegate != nullptr) {
static const auto delegate_init_cb = ActionsDelegateInitCB;
set_delegate_and_init_callback(cluster, delegate_init_cb, config->delegate);
}
@@ -364,7 +364,7 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags)
VerifyOrReturnValue(cluster, NULL, ESP_LOGE(TAG, "Could not create cluster. cluster_id: 0x%08" PRIX32, OtaSoftwareUpdateProvider::Id));
if (flags & CLUSTER_FLAG_SERVER) {
if (config -> delegate != nullptr) {
if (config && config->delegate != nullptr) {
static const auto delegate_init_cb = OtaProviderDelegateInitCB;
set_delegate_and_init_callback(cluster, delegate_init_cb, config->delegate);
}
@@ -747,7 +747,7 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags)
VerifyOrReturnValue(cluster, NULL, ESP_LOGE(TAG, "Could not create cluster. cluster_id: 0x%08" PRIX32, TimeSynchronization::Id));
if (flags & CLUSTER_FLAG_SERVER) {
if (config -> delegate != nullptr) {
if (config && config->delegate != nullptr) {
static const auto delegate_init_cb = TimeSynchronizationDelegateInitCB;
set_delegate_and_init_callback(cluster, delegate_init_cb, config->delegate);
}
@@ -1237,7 +1237,7 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags)
VerifyOrReturnValue(cluster, NULL, ESP_LOGE(TAG, "Could not create cluster. cluster_id: 0x%08" PRIX32, FanControl::Id));
if (flags & CLUSTER_FLAG_SERVER) {
if (config -> delegate != nullptr) {
if (config && config->delegate != nullptr) {
static const auto delegate_init_cb = FanControlDelegateInitCB;
set_delegate_and_init_callback(cluster, delegate_init_cb, config->delegate);
}
@@ -1433,7 +1433,7 @@ static cluster_t *create(endpoint_t *endpoint, T *config, uint8_t flags, uint32_
VerifyOrReturnValue(cluster, NULL, ESP_LOGE(TAG, "Could not create cluster, id: 0x%08" PRIX32, cluster_id));
if (flags & CLUSTER_FLAG_SERVER) {
if (config -> delegate != nullptr) {
if (config && config->delegate != nullptr) {
set_delegate_and_init_callback(cluster, delegate_init_cb, config->delegate);
}
add_function_list(cluster, function_list, function_flags);
@@ -1633,7 +1633,7 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags)
VerifyOrReturnValue(cluster, NULL, ESP_LOGE(TAG, "Could not create cluster. cluster_id: 0x%08" PRIX32, OperationalState::Id));
if (flags & CLUSTER_FLAG_SERVER) {
if (config -> delegate != nullptr) {
if (config && config->delegate != nullptr) {
static const auto delegate_init_cb = OperationalStateDelegateInitCB;
set_delegate_and_init_callback(cluster, delegate_init_cb, config->delegate);
}
@@ -1672,7 +1672,7 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags)
VerifyOrReturnValue(cluster, NULL, ESP_LOGE(TAG, "Could not create cluster. cluster_id: 0x%08" PRIX32, LaundryWasherMode::Id));
if (flags & CLUSTER_FLAG_SERVER) {
if (config && config -> delegate != nullptr) {
if (config && config->delegate != nullptr) {
static const auto delegate_init_cb = LaundryWasherModeDelegateInitCB;
set_delegate_and_init_callback(cluster, delegate_init_cb, config->delegate);
}
@@ -1761,7 +1761,7 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags)
VerifyOrReturnValue(cluster, NULL, ESP_LOGE(TAG, "Could not create cluster. cluster_id: 0x%08" PRIX32, LaundryDryerControls::Id));
if (flags & CLUSTER_FLAG_SERVER) {
if (config -> delegate != nullptr) {
if (config && config->delegate != nullptr) {
static const auto delegate_init_cb = LaundryDryerControlsDelegateInitCB;
set_delegate_and_init_callback(cluster, delegate_init_cb, config->delegate);
}
@@ -1800,7 +1800,7 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags)
if (flags & CLUSTER_FLAG_SERVER) {
add_function_list(cluster, function_list, function_flags);
if (config && config -> delegate != nullptr) {
if (config && config->delegate != nullptr) {
static const auto delegate_init_cb = DishWasherModeDelegateInitCB;
set_delegate_and_init_callback(cluster, delegate_init_cb, config->delegate);
}
@@ -1834,7 +1834,7 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags)
VerifyOrReturnValue(cluster, NULL, ESP_LOGE(TAG, "Could not create cluster. cluster_id: 0x%08" PRIX32, DishwasherAlarm::Id));
if (flags & CLUSTER_FLAG_SERVER) {
if (config && config -> delegate != nullptr) {
if (config && config->delegate != nullptr) {
static const auto delegate_init_cb = DishwasherAlarmDelegateInitCB;
set_delegate_and_init_callback(cluster, delegate_init_cb, config->delegate);
}
@@ -1922,7 +1922,7 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags)
VerifyOrReturnValue(cluster, NULL, ESP_LOGE(TAG, "Could not create cluster. cluster_id: 0x%08" PRIX32, DoorLock::Id));
if (flags & CLUSTER_FLAG_SERVER) {
if (config && config -> delegate != nullptr) {
if (config && config->delegate != nullptr) {
static const auto delegate_init_cb = DoorLockDelegateInitCB;
set_delegate_and_init_callback(cluster, delegate_init_cb, config->delegate);
}
@@ -1978,7 +1978,7 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags)
static const auto plugin_server_init_cb = CALL_ONCE(MatterWindowCoveringPluginServerInitCallback);
set_plugin_server_init_callback(cluster, plugin_server_init_cb);
if (config && config -> delegate != nullptr) {
if (config->delegate != nullptr) {
static const auto delegate_init_cb = WindowCoveringDelegateInitCB;
set_delegate_and_init_callback(cluster, delegate_init_cb, config->delegate);
}
@@ -2277,7 +2277,7 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags)
VerifyOrReturnValue(cluster, NULL, ESP_LOGE(TAG, "Could not create cluster. cluster_id: 0x%08" PRIX32, BooleanStateConfiguration::Id));
if (flags & CLUSTER_FLAG_SERVER) {
if (config && config -> delegate != nullptr) {
if (config && config->delegate != nullptr) {
static const auto delegate_init_cb = BooleanStateConfigurationDelegateInitCB;
set_delegate_and_init_callback(cluster, delegate_init_cb, config->delegate);
}
@@ -2559,7 +2559,7 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags)
cluster_t *cluster = cluster::create(endpoint, ModeSelect::Id, flags);
VerifyOrReturnValue(cluster, NULL, ESP_LOGE(TAG, "Could not create cluster. cluster_id: 0x%08" PRIX32, ModeSelect::Id));
if (flags & CLUSTER_FLAG_SERVER) {
if (config -> delegate != nullptr) {
if (config && config->delegate != nullptr) {
static const auto delegate_init_cb = ModeSelectDelegateInitCB;
set_delegate_and_init_callback(cluster, delegate_init_cb, config->delegate);
}
@@ -2601,7 +2601,7 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags)
cluster_t *cluster = cluster::create(endpoint, DiagnosticLogs::Id, flags);
if (flags & CLUSTER_FLAG_SERVER) {
if (config -> delegate != nullptr) {
if (config && config->delegate != nullptr) {
static const auto delegate_init_cb = DiagnosticLogsDelegateInitCB;
set_delegate_and_init_callback(cluster, delegate_init_cb, config->delegate);
}
@@ -2739,7 +2739,7 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags)
VerifyOrReturnValue(cluster, NULL, ESP_LOGE(TAG, "Could not create cluster. cluster_id: 0x%08" PRIX32, RefrigeratorAndTemperatureControlledCabinetMode::Id));
if (flags & CLUSTER_FLAG_SERVER) {
if (config && config -> delegate != nullptr) {
if (config && config->delegate != nullptr) {
static const auto delegate_init_cb = RefrigeratorAndTCCModeDelegateInitCB;
set_delegate_and_init_callback(cluster, delegate_init_cb, config->delegate);
}
@@ -2777,7 +2777,7 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags)
VerifyOrReturnValue(cluster, NULL, ESP_LOGE(TAG, "Could not create cluster. cluster_id: 0x%08" PRIX32, RvcRunMode::Id));
if (flags & CLUSTER_FLAG_SERVER) {
if (config && config -> delegate != nullptr) {
if (config && config->delegate != nullptr) {
static const auto delegate_init_cb = RvcRunModeDelegateInitCB;
set_delegate_and_init_callback(cluster, delegate_init_cb, config->delegate);
}
@@ -2815,7 +2815,7 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags)
VerifyOrReturnValue(cluster, NULL, ESP_LOGE(TAG, "Could not create cluster. cluster_id: 0x%08" PRIX32, RvcCleanMode::Id));
if (flags & CLUSTER_FLAG_SERVER) {
if (config && config -> delegate != nullptr) {
if (config && config->delegate != nullptr) {
static const auto delegate_init_cb = RvcCleanModeDelegateInitCB;
set_delegate_and_init_callback(cluster, delegate_init_cb, config->delegate);
}
@@ -2852,7 +2852,7 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags)
VerifyOrReturnValue(cluster, NULL, ESP_LOGE(TAG, "Could not create cluster. cluster_id: 0x%08" PRIX32, MicrowaveOvenMode::Id));
if (flags & CLUSTER_FLAG_SERVER) {
if (config -> delegate != nullptr) {
if (config && config->delegate != nullptr) {
static const auto delegate_init_cb = MicrowaveOvenModeDelegateInitCB;
set_delegate_and_init_callback(cluster, delegate_init_cb, config->delegate);
}
@@ -2958,7 +2958,7 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags)
}
if (flags & CLUSTER_FLAG_SERVER) {
if (config && config -> delegate != nullptr) {
if (config && config->delegate != nullptr) {
static const auto delegate_init_cb = KeypadInputDelegateInitCB;
set_delegate_and_init_callback(cluster, delegate_init_cb, config->delegate);
}
@@ -3137,7 +3137,7 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags)
VerifyOrReturnValue(cluster, NULL, ESP_LOGE(TAG, "Could not create cluster. cluster_id: 0x%08" PRIX32, EnergyEvseMode::Id));
if (flags & CLUSTER_FLAG_SERVER) {
if (config -> delegate != nullptr) {
if (config && config->delegate != nullptr) {
static const auto delegate_init_cb = EnergyEvseModeDelegateInitCB;
set_delegate_and_init_callback(cluster, delegate_init_cb, config->delegate);
}
@@ -3174,7 +3174,7 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags)
VerifyOrReturnValue(cluster, NULL, ESP_LOGE(TAG, "Could not create cluster. cluster_id: 0x%08" PRIX32, EnergyEvse::Id));
if (flags & CLUSTER_FLAG_SERVER) {
if (config -> delegate != nullptr) {
if (config && config->delegate != nullptr) {
static const auto delegate_init_cb = EnergyEvseDelegateInitCB;
set_delegate_and_init_callback(cluster, delegate_init_cb, config->delegate);
}
@@ -3215,7 +3215,7 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags)
cluster_t *cluster = cluster::create(endpoint, ValveConfigurationAndControl::Id, flags);
VerifyOrReturnValue(cluster, NULL, ESP_LOGE(TAG, "Could not create cluster. cluster_id: 0x%08" PRIX32, ValveConfigurationAndControl::Id));
if (flags & CLUSTER_FLAG_SERVER) {
if (config -> delegate != nullptr) {
if (config && config->delegate != nullptr) {
static const auto delegate_init_cb = ValveConfigurationAndControlDelegateInitCB;
set_delegate_and_init_callback(cluster, delegate_init_cb, config->delegate);
}
@@ -3260,7 +3260,7 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags)
cluster_t *cluster = cluster::create(endpoint, DeviceEnergyManagement::Id, flags);
VerifyOrReturnValue(cluster, NULL, ESP_LOGE(TAG, "Could not create cluster. cluster_id: 0x%08" PRIX32, DeviceEnergyManagement::Id));
if (flags & CLUSTER_FLAG_SERVER) {
if (config -> delegate != nullptr) {
if (config && config->delegate != nullptr) {
static const auto delegate_init_cb = DeviceEnergyManagementDelegateInitCB;
set_delegate_and_init_callback(cluster, delegate_init_cb, config->delegate);
}
@@ -3299,7 +3299,7 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags)
VerifyOrReturnValue(cluster, NULL, ESP_LOGE(TAG, "Could not create cluster. cluster_id: 0x%08" PRIX32, DeviceEnergyManagementMode::Id));
if (flags & CLUSTER_FLAG_SERVER) {
if (config -> delegate != nullptr) {
if (config && config->delegate != nullptr) {
static const auto delegate_init_cb = DeviceEnergyManagementModeDelegateInitCB;
set_delegate_and_init_callback(cluster, delegate_init_cb, config->delegate);
}
@@ -3335,7 +3335,7 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags)
cluster_t *cluster = cluster::create(endpoint, ApplicationBasic::Id, flags);
VerifyOrReturnValue(cluster, NULL, ESP_LOGE(TAG, "Could not create cluster. cluster_id: 0x%08" PRIX32, ApplicationBasic::Id));
if (flags & CLUSTER_FLAG_SERVER) {
if (config -> delegate != nullptr) {
if (config && config->delegate != nullptr) {
static const auto delegate_init_cb = ApplicationBasicDelegateInitCB;
set_delegate_and_init_callback(cluster, delegate_init_cb, config->delegate);
}
@@ -3373,7 +3373,7 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags)
cluster_t *cluster = cluster::create(endpoint, ThreadBorderRouterManagement::Id, flags);
VerifyOrReturnValue(cluster, NULL, ESP_LOGE(TAG, "Could not create cluster"));
if (flags & CLUSTER_FLAG_SERVER) {
if (config -> delegate != nullptr) {
if (config && config->delegate != nullptr) {
static const auto delegate_init_cb = ThreadBorderRouterManagementDelegateInitCB;
set_delegate_and_init_callback(cluster, delegate_init_cb, config->delegate);
}
@@ -3487,7 +3487,7 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags)
return NULL;
}
if (flags & CLUSTER_FLAG_SERVER) {
if (config -> delegate != nullptr) {
if (config && config->delegate != nullptr) {
static const auto delegate_init_cb = ServiceAreaDelegateInitCB;
set_delegate_and_init_callback(cluster, delegate_init_cb, config->delegate);
}
@@ -3524,7 +3524,7 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags)
return NULL;
}
if (flags & CLUSTER_FLAG_SERVER) {
if (config -> delegate != nullptr) {
if (config && config->delegate != nullptr) {
static const auto delegate_init_cb = WaterHeaterManagementDelegateInitCB;
set_delegate_and_init_callback(cluster, delegate_init_cb, config->delegate);
}
@@ -3565,7 +3565,7 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags)
}
if (flags & CLUSTER_FLAG_SERVER) {
if (config && config -> delegate != nullptr) {
if (config && config->delegate != nullptr) {
static const auto delegate_init_cb = WaterHeaterModeDelegateInitCB;
set_delegate_and_init_callback(cluster, delegate_init_cb, config->delegate);
}
@@ -3652,7 +3652,7 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags)
return NULL;
}
if (flags & CLUSTER_FLAG_SERVER) {
if (config -> delegate != nullptr) {
if (config && config->delegate != nullptr) {
static const auto delegate_init_cb = CommissionerControlDelegateInitCB;
set_delegate_and_init_callback(cluster, delegate_init_cb, config->delegate);
}