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 c894d6debe
commit 97b805d214
@@ -224,7 +224,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);
}
@@ -368,7 +368,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 = OtaSoftwareUpdateProviderDelegateInitCB;
set_delegate_and_init_callback(cluster, delegate_init_cb, config->delegate);
}
@@ -812,7 +812,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);
}
@@ -1299,7 +1299,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);
}
@@ -1495,7 +1495,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);
@@ -1684,7 +1684,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);
}
@@ -1723,7 +1723,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);
}
@@ -1812,7 +1812,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);
}
@@ -1851,7 +1851,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);
}
@@ -1885,7 +1885,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);
}
@@ -1973,7 +1973,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);
}
@@ -2029,7 +2029,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);
}
@@ -2332,7 +2332,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);
}
@@ -2614,7 +2614,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);
}
@@ -2656,7 +2656,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);
}
@@ -2796,7 +2796,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);
}
@@ -2834,7 +2834,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);
}
@@ -2872,7 +2872,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);
}
@@ -2909,7 +2909,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);
}
@@ -3031,7 +3031,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);
}
@@ -3210,7 +3210,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);
}
@@ -3247,7 +3247,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);
}
@@ -3288,7 +3288,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);
}
@@ -3333,7 +3333,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);
}
@@ -3372,7 +3372,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);
}
@@ -3408,7 +3408,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);
}
@@ -3446,7 +3446,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);
}
@@ -3563,7 +3563,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);
}
@@ -3600,7 +3600,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);
}
@@ -3641,7 +3641,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);
}
@@ -3728,7 +3728,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);
}