mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 0/2] ASoC: codecs: lpass-{tx,wsa}-macro: fix enum kcontrol accesses
@ 2026-07-29 19:38 Dawid Wróbel via B4 Relay
  2026-07-29 19:38 ` [PATCH 1/2] ASoC: codecs: lpass-tx-macro: Fix " Dawid Wróbel via B4 Relay
  2026-07-29 19:38 ` [PATCH 2/2] ASoC: codecs: lpass-wsa-macro: " Dawid Wróbel via B4 Relay
  0 siblings, 2 replies; 5+ messages in thread
From: Dawid Wróbel via B4 Relay @ 2026-07-29 19:38 UTC (permalink / raw)
  To: Srinivas Kandagatla, Liam Girdwood, Mark Brown, Jaroslav Kysela,
	Takashi Iwai, Pierre-Louis Bossart
  Cc: linux-sound, linux-arm-msm, linux-kernel, Dawid Wróbel

Both drivers access enumerated controls through value.integer.value[0]
instead of value.enumerated.item[0]. The same bug was fixed in rx-macro
and va-macro in 2022 (bcfe5f76cc40, 0ea5eff7c606); tx-macro and
wsa-macro were missed.

On 64-bit kernels with CONFIG_SND_CTL_DEBUG this trips the elem value
sanity check, and every read of the affected controls fails with
-EINVAL.

Reproduced and fixed on a Xiaomi Mi Pad 5 Pro (SM8250) for tx-macro.
wsa-macro is compile-tested only — that codec is not instantiated on
this hardware.

Signed-off-by: Dawid Wróbel <me@dawidwrobel.com>
---
Dawid Wróbel (2):
      ASoC: codecs: lpass-tx-macro: Fix enum kcontrol accesses
      ASoC: codecs: lpass-wsa-macro: Fix enum kcontrol accesses

 sound/soc/codecs/lpass-tx-macro.c  | 4 ++--
 sound/soc/codecs/lpass-wsa-macro.c | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)
---
base-commit: 57b8e2d666a31fa201432d58f5fe3469a0dd83ba
change-id: 20260729-worktree-lpass-tx-macro-enum-fix-c5fbafef75b6

Best regards,
-- 
Dawid Wróbel <me@dawidwrobel.com>



^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 1/2] ASoC: codecs: lpass-tx-macro: Fix enum kcontrol accesses
  2026-07-29 19:38 [PATCH 0/2] ASoC: codecs: lpass-{tx,wsa}-macro: fix enum kcontrol accesses Dawid Wróbel via B4 Relay
@ 2026-07-29 19:38 ` Dawid Wróbel via B4 Relay
  2026-07-29 23:02   ` Srinivas Kandagatla
  2026-07-29 19:38 ` [PATCH 2/2] ASoC: codecs: lpass-wsa-macro: " Dawid Wróbel via B4 Relay
  1 sibling, 1 reply; 5+ messages in thread
From: Dawid Wróbel via B4 Relay @ 2026-07-29 19:38 UTC (permalink / raw)
  To: Srinivas Kandagatla, Liam Girdwood, Mark Brown, Jaroslav Kysela,
	Takashi Iwai, Pierre-Louis Bossart
  Cc: linux-sound, linux-arm-msm, linux-kernel, Dawid Wróbel

From: Dawid Wróbel <me@dawidwrobel.com>

The "DEC0 MODE" to "DEC7 MODE" controls are enumerated, but
tx_macro_dec_mode_get() and tx_macro_dec_mode_put() access their
value through ucontrol->value.integer.value[0] (a long) instead of
ucontrol->value.enumerated.item[0] (an unsigned int).

This same pattern was fixed in the sibling drivers by
commit bcfe5f76cc40 ("ASoC: codecs: rx-macro: fix accessing array
out of bounds for enum type") and
commit 0ea5eff7c606 ("ASoC: codecs: va-macro: fix accessing array
out of bounds for enum type"), but tx-macro was missed.

On 64-bit kernels built with CONFIG_SND_CTL_DEBUG, the elem value
sanity check catches the 4 bytes written past the enumerated item
and every read of these controls fails with -EINVAL:

  snd-sm8250 sound: control 2:0:0:DEC0 MODE:0: access overflow

Fixes: c39667ddcfc5 ("ASoC: codecs: lpass-tx-macro: add support for lpass tx macro")
Assisted-by: Claude:claude-fable-5
Signed-off-by: Dawid Wróbel <me@dawidwrobel.com>
---
 sound/soc/codecs/lpass-tx-macro.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/sound/soc/codecs/lpass-tx-macro.c b/sound/soc/codecs/lpass-tx-macro.c
index f7d168f557dd..0cbf50647ff5 100644
--- a/sound/soc/codecs/lpass-tx-macro.c
+++ b/sound/soc/codecs/lpass-tx-macro.c
@@ -1075,7 +1075,7 @@ static int tx_macro_dec_mode_get(struct snd_kcontrol *kcontrol,
 	struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
 	int path = e->shift_l;
 
-	ucontrol->value.integer.value[0] = tx->dec_mode[path];
+	ucontrol->value.enumerated.item[0] = tx->dec_mode[path];
 
 	return 0;
 }
@@ -1084,7 +1084,7 @@ static int tx_macro_dec_mode_put(struct snd_kcontrol *kcontrol,
 				 struct snd_ctl_elem_value *ucontrol)
 {
 	struct snd_soc_component *component = snd_kcontrol_chip(kcontrol);
-	int value = ucontrol->value.integer.value[0];
+	int value = ucontrol->value.enumerated.item[0];
 	struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
 	int path = e->shift_l;
 	struct tx_macro *tx = snd_soc_component_get_drvdata(component);

-- 
2.55.0



^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 2/2] ASoC: codecs: lpass-wsa-macro: Fix enum kcontrol accesses
  2026-07-29 19:38 [PATCH 0/2] ASoC: codecs: lpass-{tx,wsa}-macro: fix enum kcontrol accesses Dawid Wróbel via B4 Relay
  2026-07-29 19:38 ` [PATCH 1/2] ASoC: codecs: lpass-tx-macro: Fix " Dawid Wróbel via B4 Relay
@ 2026-07-29 19:38 ` Dawid Wróbel via B4 Relay
  2026-07-29 23:01   ` Srinivas Kandagatla
  1 sibling, 1 reply; 5+ messages in thread
From: Dawid Wróbel via B4 Relay @ 2026-07-29 19:38 UTC (permalink / raw)
  To: Srinivas Kandagatla, Liam Girdwood, Mark Brown, Jaroslav Kysela,
	Takashi Iwai, Pierre-Louis Bossart
  Cc: linux-sound, linux-arm-msm, linux-kernel, Dawid Wróbel

From: Dawid Wróbel <me@dawidwrobel.com>

The "EAR SPKR PA Gain" control is enumerated, but
wsa_macro_ear_spkr_pa_gain_get() and _put() access its value
through ucontrol->value.integer.value[0] (a long) instead of
ucontrol->value.enumerated.item[0] (an unsigned int).

This same pattern was fixed in the sibling drivers by
commit bcfe5f76cc40 ("ASoC: codecs: rx-macro: fix accessing array
out of bounds for enum type") and
commit 0ea5eff7c606 ("ASoC: codecs: va-macro: fix accessing array
out of bounds for enum type"), but wsa-macro was missed.

On 64-bit kernels built with CONFIG_SND_CTL_DEBUG, the elem value
sanity check catches the 4 bytes written past the enumerated item
and every read of this control fails with -EINVAL (access overflow).

Fixes: 809bcbcecebf ("ASoC: codecs: lpass-wsa-macro: Add support to WSA Macro")
Assisted-by: Claude:claude-fable-5
Signed-off-by: Dawid Wróbel <me@dawidwrobel.com>
---
 sound/soc/codecs/lpass-wsa-macro.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/sound/soc/codecs/lpass-wsa-macro.c b/sound/soc/codecs/lpass-wsa-macro.c
index 5ad0448af649..c88d13c0770b 100644
--- a/sound/soc/codecs/lpass-wsa-macro.c
+++ b/sound/soc/codecs/lpass-wsa-macro.c
@@ -2064,7 +2064,7 @@ static int wsa_macro_ear_spkr_pa_gain_get(struct snd_kcontrol *kcontrol,
 	struct snd_soc_component *component = snd_kcontrol_chip(kcontrol);
 	struct wsa_macro *wsa = snd_soc_component_get_drvdata(component);
 
-	ucontrol->value.integer.value[0] = wsa->ear_spkr_gain;
+	ucontrol->value.enumerated.item[0] = wsa->ear_spkr_gain;
 
 	return 0;
 }
@@ -2075,7 +2075,7 @@ static int wsa_macro_ear_spkr_pa_gain_put(struct snd_kcontrol *kcontrol,
 	struct snd_soc_component *component = snd_kcontrol_chip(kcontrol);
 	struct wsa_macro *wsa = snd_soc_component_get_drvdata(component);
 
-	wsa->ear_spkr_gain =  ucontrol->value.integer.value[0];
+	wsa->ear_spkr_gain =  ucontrol->value.enumerated.item[0];
 
 	return 0;
 }

-- 
2.55.0



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 2/2] ASoC: codecs: lpass-wsa-macro: Fix enum kcontrol accesses
  2026-07-29 19:38 ` [PATCH 2/2] ASoC: codecs: lpass-wsa-macro: " Dawid Wróbel via B4 Relay
@ 2026-07-29 23:01   ` Srinivas Kandagatla
  0 siblings, 0 replies; 5+ messages in thread
From: Srinivas Kandagatla @ 2026-07-29 23:01 UTC (permalink / raw)
  To: me, Srinivas Kandagatla, Liam Girdwood, Mark Brown,
	Jaroslav Kysela, Takashi Iwai, Pierre-Louis Bossart
  Cc: linux-sound, linux-arm-msm, linux-kernel

On 7/29/26 8:38 PM, Dawid Wróbel via B4 Relay wrote:
> From: Dawid Wróbel <me@dawidwrobel.com>
> 
> The "EAR SPKR PA Gain" control is enumerated, but
> wsa_macro_ear_spkr_pa_gain_get() and _put() access its value
> through ucontrol->value.integer.value[0] (a long) instead of
> ucontrol->value.enumerated.item[0] (an unsigned int).
> 
> This same pattern was fixed in the sibling drivers by
> commit bcfe5f76cc40 ("ASoC: codecs: rx-macro: fix accessing array
> out of bounds for enum type") and
> commit 0ea5eff7c606 ("ASoC: codecs: va-macro: fix accessing array
> out of bounds for enum type"), but wsa-macro was missed.
> 
> On 64-bit kernels built with CONFIG_SND_CTL_DEBUG, the elem value
> sanity check catches the 4 bytes written past the enumerated item
> and every read of this control fails with -EINVAL (access overflow).
> 
> Fixes: 809bcbcecebf ("ASoC: codecs: lpass-wsa-macro: Add support to WSA Macro")
> Assisted-by: Claude:claude-fable-5
> Signed-off-by: Dawid Wróbel <me@dawidwrobel.com>
> ---
>  sound/soc/codecs/lpass-wsa-macro.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 

Thanks for fixing these,

while you are at it , can you also fix wsa_macro_rx_mux_put too, it
seems to suffer the same issue.

Also can you add CC Stable.

--srini

> diff --git a/sound/soc/codecs/lpass-wsa-macro.c b/sound/soc/codecs/lpass-wsa-macro.c
> index 5ad0448af649..c88d13c0770b 100644
> --- a/sound/soc/codecs/lpass-wsa-macro.c
> +++ b/sound/soc/codecs/lpass-wsa-macro.c
> @@ -2064,7 +2064,7 @@ static int wsa_macro_ear_spkr_pa_gain_get(struct snd_kcontrol *kcontrol,
>  	struct snd_soc_component *component = snd_kcontrol_chip(kcontrol);
>  	struct wsa_macro *wsa = snd_soc_component_get_drvdata(component);
>  
> -	ucontrol->value.integer.value[0] = wsa->ear_spkr_gain;
> +	ucontrol->value.enumerated.item[0] = wsa->ear_spkr_gain;
>  
>  	return 0;
>  }
> @@ -2075,7 +2075,7 @@ static int wsa_macro_ear_spkr_pa_gain_put(struct snd_kcontrol *kcontrol,
>  	struct snd_soc_component *component = snd_kcontrol_chip(kcontrol);
>  	struct wsa_macro *wsa = snd_soc_component_get_drvdata(component);
>  
> -	wsa->ear_spkr_gain =  ucontrol->value.integer.value[0];
> +	wsa->ear_spkr_gain =  ucontrol->value.enumerated.item[0];
>  
>  	return 0;
>  }
> 


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/2] ASoC: codecs: lpass-tx-macro: Fix enum kcontrol accesses
  2026-07-29 19:38 ` [PATCH 1/2] ASoC: codecs: lpass-tx-macro: Fix " Dawid Wróbel via B4 Relay
@ 2026-07-29 23:02   ` Srinivas Kandagatla
  0 siblings, 0 replies; 5+ messages in thread
From: Srinivas Kandagatla @ 2026-07-29 23:02 UTC (permalink / raw)
  To: me, Srinivas Kandagatla, Liam Girdwood, Mark Brown,
	Jaroslav Kysela, Takashi Iwai, Pierre-Louis Bossart
  Cc: linux-sound, linux-arm-msm, linux-kernel

On 7/29/26 8:38 PM, Dawid Wróbel via B4 Relay wrote:
> From: Dawid Wróbel <me@dawidwrobel.com>
> 
> The "DEC0 MODE" to "DEC7 MODE" controls are enumerated, but
> tx_macro_dec_mode_get() and tx_macro_dec_mode_put() access their
> value through ucontrol->value.integer.value[0] (a long) instead of
> ucontrol->value.enumerated.item[0] (an unsigned int).
> 
> This same pattern was fixed in the sibling drivers by
> commit bcfe5f76cc40 ("ASoC: codecs: rx-macro: fix accessing array
> out of bounds for enum type") and
> commit 0ea5eff7c606 ("ASoC: codecs: va-macro: fix accessing array
> out of bounds for enum type"), but tx-macro was missed.
> 
> On 64-bit kernels built with CONFIG_SND_CTL_DEBUG, the elem value
> sanity check catches the 4 bytes written past the enumerated item
> and every read of these controls fails with -EINVAL:
> 
>   snd-sm8250 sound: control 2:0:0:DEC0 MODE:0: access overflow
> 
> Fixes: c39667ddcfc5 ("ASoC: codecs: lpass-tx-macro: add support for lpass tx macro")
> Assisted-by: Claude:claude-fable-5
> Signed-off-by: Dawid Wróbel <me@dawidwrobel.com>

CC Stable

Once added


Reviewed-by: Srinivas Kandagatla <srinivas.kandagatla@oss.qualcomm.com>

--srini
> ---
>  sound/soc/codecs/lpass-tx-macro.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/sound/soc/codecs/lpass-tx-macro.c b/sound/soc/codecs/lpass-tx-macro.c
> index f7d168f557dd..0cbf50647ff5 100644
> --- a/sound/soc/codecs/lpass-tx-macro.c
> +++ b/sound/soc/codecs/lpass-tx-macro.c
> @@ -1075,7 +1075,7 @@ static int tx_macro_dec_mode_get(struct snd_kcontrol *kcontrol,
>  	struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
>  	int path = e->shift_l;
>  
> -	ucontrol->value.integer.value[0] = tx->dec_mode[path];
> +	ucontrol->value.enumerated.item[0] = tx->dec_mode[path];
>  
>  	return 0;
>  }
> @@ -1084,7 +1084,7 @@ static int tx_macro_dec_mode_put(struct snd_kcontrol *kcontrol,
>  				 struct snd_ctl_elem_value *ucontrol)
>  {
>  	struct snd_soc_component *component = snd_kcontrol_chip(kcontrol);
> -	int value = ucontrol->value.integer.value[0];
> +	int value = ucontrol->value.enumerated.item[0];
>  	struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
>  	int path = e->shift_l;
>  	struct tx_macro *tx = snd_soc_component_get_drvdata(component);
> 


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-07-29 23:02 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-07-29 19:38 [PATCH 0/2] ASoC: codecs: lpass-{tx,wsa}-macro: fix enum kcontrol accesses Dawid Wróbel via B4 Relay
2026-07-29 19:38 ` [PATCH 1/2] ASoC: codecs: lpass-tx-macro: Fix " Dawid Wróbel via B4 Relay
2026-07-29 23:02   ` Srinivas Kandagatla
2026-07-29 19:38 ` [PATCH 2/2] ASoC: codecs: lpass-wsa-macro: " Dawid Wróbel via B4 Relay
2026-07-29 23:01   ` Srinivas Kandagatla

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®