thesofproject / sof

Sound Open Firmware
Other
547 stars 314 forks source link

[BUG] the potential issue on codec_adapter_new() error caused by large config private data #5866

Open johnylin76 opened 2 years ago

johnylin76 commented 2 years ago

Describe the bug The topology is failed to load due to the error on codec_adapter_new() if we put the codec-specific config to the private data of either setup or runtime config byte-control. (e.g. put the default setting to runtime config)

The root cause is in sof-kernel while allocating a new comp under sof_process_load() the IPC tx message may append the private data of control widgets for that comp, or sent them separately if the message length exceeds the max IPC size after appending (reference).

The latter case will cause the error in codec_adapter_new() because it always assumes the 20-byte ca_config is appended as setup config (reference).

In main stream I saw that the config loading is skipped if the input size is 0 (the latter case) in module_adapter_new(). However I still wonder if there is the risk to process module_init() without any config loaded (especially for the setup config.)

To Reproduce For the FW built under adl-004-drop-stable with linux kernel version not greater than v5.17, attach a large config blob to the private data of either setup or runtime control for codec_adapter comps. (example)

Reproduction Rate 10/10

Expected behavior The topology is loaded successfully. Moreover, (as module_adapter in main stream) module_init() should be processed after the setup config is set by module_load_config().

Impact Cannot add the default value of codec-specific params in the private data.

lgirdwood commented 2 years ago

@mwasko fyi issue on ADL-04 branch @ranj063 does this also apply to the main branch ? (if so, maybe a single fix is needed)