[PATCH 2/6] ASoC: codecs: pm4125: add compander channels to the RX channel table

From: Riccardo Mereu

Date: Tue Dec 01 2026 - 08:12:39 EST


From: Riccardo Mereu <r.mereu@xxxxxxxxxx>

The HPHL_COMP and HPHR_COMP switches pass PM4125_COMP_L and
PM4125_COMP_R as channel index to pm4125_connect_port(), but
pm4125_sdw_rx_ch_info[] only has entries for PM4125_HPH_L and
PM4125_HPH_R. The lookup reads past the end of the table and the port
number it returns is used, minus one, to index sdw_priv->port_config[].
That writes outside the array, onto the fields around it, including
the sruntime pointer just before it.

On the Arduino UNO Q this crashes in two ways: when alsactl restores
the compander switches at boot,

Unable to handle kernel write to read-only memory at virtual address ffff0000c7e3a0e0
pc : pm4125_connect_port.isra.0+0x2c/0x78 [snd_soc_pm4125]
lr : pm4125_set_compander+0x84/0xa0 [snd_soc_pm4125]

and on the next hw_free after a compander switch changed the stream
pointer:

Unable to handle kernel paging request at virtual address ffffffffffffffe0
pc : sdw_slave_port_free+0x48/0x110 [soundwire_bus]
lr : sdw_stream_remove_slave+0x3c/0x74 [soundwire_bus]
Call trace:
sdw_slave_port_free+0x48/0x110 [soundwire_bus] (P)
sdw_stream_remove_slave+0x3c/0x74 [soundwire_bus]
pm4125_codec_free+0x2c/0x40 [snd_soc_pm4125]
snd_soc_dai_hw_free+0x54/0x68 [snd_soc_core]

The driver already defines PM4125_COMP_PORT. Add the two compander
channels on it to the RX table, as wcd937x does.

Fixes: 8ad529484937 ("ASoC: codecs: add new pm4125 audio codec driver")
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Riccardo Mereu <r.mereu@xxxxxxxxxx>
---
sound/soc/codecs/pm4125-sdw.c | 2 ++
1 file changed, 2 insertions(+)

diff --git a/sound/soc/codecs/pm4125-sdw.c b/sound/soc/codecs/pm4125-sdw.c
index c279bf0a88b1..06d51b185e6a 100644
--- a/sound/soc/codecs/pm4125-sdw.c
+++ b/sound/soc/codecs/pm4125-sdw.c
@@ -23,6 +23,8 @@
static struct wcd_sdw_ch_info pm4125_sdw_rx_ch_info[] = {
WCD_SDW_CH(PM4125_HPH_L, PM4125_HPH_PORT, BIT(0)),
WCD_SDW_CH(PM4125_HPH_R, PM4125_HPH_PORT, BIT(1)),
+ WCD_SDW_CH(PM4125_COMP_L, PM4125_COMP_PORT, BIT(0)),
+ WCD_SDW_CH(PM4125_COMP_R, PM4125_COMP_PORT, BIT(1)),
};

static struct wcd_sdw_ch_info pm4125_sdw_tx_ch_info[] = {
--
2.56.1


--





Privacy and Confidentiality Notice: This email and all attachments are
confidential and for the designated recipient(s) only. They may also be
privileged. If you are not the intended recipient or among the intended
recipients, you may not use, read, retransmit, disseminate, store/copy the
information in any medium or take any action in reliance upon it. Please
notify the sender that you have received it in error and immediately delete
the entire communication, including any attachments.