ASoC: SOF: ipc4-topology: Fix shift-out-of-bounds for aggregated ALH capture

There's a out of bounds error with the 7.2 kernel seen on some devices. Reproduced on the Lenovo T14s G7 (but likely impacts other platforms) Upstream commit, detailed below, fixes it. Upstream conversation is here: https://github.com/thesofproject/sof-bin/issues/213


When ch_count is smaller than blob->alh_cfg.device_count (e.g. a mono capture stream, such as a SmartMic, aggregated across multiple SDW links), step = ch_count / blob->alh_cfg.device_count truncates to 0. The subsequent GENMASK(step - 1, 0) then underflows step - 1 (u32) to UINT_MAX, causing GENMASK()'s internal shift to use an out-of-bounds exponent:

UBSAN: shift-out-of-bounds in sound/soc/sof/ipc4-topology.c:2363:13 shift exponent 18446744069414584384 is too large for 64-bit type 'long unsigned int'

Treat ch_count < device_count the same way as the existing "channels equal to output reference channels" case: apply the same ch_mask to every aggregated device instead of trying to split channels that can't be evenly divided.

Fixes: 0390a102 ("ASoC: SOF: ipc4-topology: use different channel mask for each sdw amp feedback") Cc: stable@vger.kernel.org Signed-off-by: Peter Ujfalusi peter.ujfalusi@linux.intel.com

Upstream Status: https://github.com/thesofproject/linux (cherry picked from commit b4bc873561db55f8ed1bb4113797d768424f300d) Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2537121 Tested-by: Mark Pearson mpearson-lenovo@squebb.ca Signed-off-by: Mark Pearson mpearson-lenovo@squebb.ca

Merge request reports

Loading
Loading