All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] ALSA: Fix for bad ctl access patterns
@ 2020-04-07  8:44 Takashi Iwai
  2020-04-07  8:44 ` [PATCH 1/2] ALSA: hda: Fix potential access overflow in beep helper Takashi Iwai
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Takashi Iwai @ 2020-04-07  8:44 UTC (permalink / raw)
  To: alsa-devel

Hi,

the recently introduced ctl access validator succeessfully caught some
real issues.  Here are some fixes.


Takashi

===

Takashi Iwai (2):
  ALSA: hda: Fix potential access overflow in beep helper
  ALSA: ice1724: Fix invalid access for enumerated ctl items

 sound/pci/hda/hda_beep.c         | 6 +++++-
 sound/pci/ice1712/prodigy_hifi.c | 4 ++--
 2 files changed, 7 insertions(+), 3 deletions(-)

-- 
2.25.0


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

* [PATCH 1/2] ALSA: hda: Fix potential access overflow in beep helper
  2020-04-07  8:44 [PATCH 0/2] ALSA: Fix for bad ctl access patterns Takashi Iwai
@ 2020-04-07  8:44 ` Takashi Iwai
  2020-04-07  8:44 ` [PATCH 2/2] ALSA: ice1724: Fix invalid access for enumerated ctl items Takashi Iwai
  2020-04-07 14:30 ` [PATCH 0/2] ALSA: Fix for bad ctl access patterns Jaroslav Kysela
  2 siblings, 0 replies; 4+ messages in thread
From: Takashi Iwai @ 2020-04-07  8:44 UTC (permalink / raw)
  To: alsa-devel

The beep control helper function blindly stores the values in two
stereo channels no matter whether the actual control is mono or
stereo.  This is practically harmless, but it annoys the recently
introduced sanity check, resulting in an error when the checker is
enabled.

This patch corrects the behavior to store only on the defined array
member.

BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=207139
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
 sound/pci/hda/hda_beep.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/sound/pci/hda/hda_beep.c b/sound/pci/hda/hda_beep.c
index f5fd62ed4df5..841523f6b88d 100644
--- a/sound/pci/hda/hda_beep.c
+++ b/sound/pci/hda/hda_beep.c
@@ -290,8 +290,12 @@ int snd_hda_mixer_amp_switch_get_beep(struct snd_kcontrol *kcontrol,
 {
 	struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
 	struct hda_beep *beep = codec->beep;
+	int chs = get_amp_channels(kcontrol);
+
 	if (beep && (!beep->enabled || !ctl_has_mute(kcontrol))) {
-		ucontrol->value.integer.value[0] =
+		if (chs & 1)
+			ucontrol->value.integer.value[0] = beep->enabled;
+		if (chs & 2)
 			ucontrol->value.integer.value[1] = beep->enabled;
 		return 0;
 	}
-- 
2.25.0


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

* [PATCH 2/2] ALSA: ice1724: Fix invalid access for enumerated ctl items
  2020-04-07  8:44 [PATCH 0/2] ALSA: Fix for bad ctl access patterns Takashi Iwai
  2020-04-07  8:44 ` [PATCH 1/2] ALSA: hda: Fix potential access overflow in beep helper Takashi Iwai
@ 2020-04-07  8:44 ` Takashi Iwai
  2020-04-07 14:30 ` [PATCH 0/2] ALSA: Fix for bad ctl access patterns Jaroslav Kysela
  2 siblings, 0 replies; 4+ messages in thread
From: Takashi Iwai @ 2020-04-07  8:44 UTC (permalink / raw)
  To: alsa-devel

The access to Analog Capture Source control value implemented in
prodigy_hifi.c is wrong, as caught by the recently introduced sanity
check; it should be accessing value.enumerated.item[] instead of
value.integer.value[].  This patch corrects the wrong access pattern.

BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=207139
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
 sound/pci/ice1712/prodigy_hifi.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/sound/pci/ice1712/prodigy_hifi.c b/sound/pci/ice1712/prodigy_hifi.c
index 91f83cef0e56..9aa12a67d370 100644
--- a/sound/pci/ice1712/prodigy_hifi.c
+++ b/sound/pci/ice1712/prodigy_hifi.c
@@ -536,7 +536,7 @@ static int wm_adc_mux_enum_get(struct snd_kcontrol *kcontrol,
 	struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
 
 	mutex_lock(&ice->gpio_mutex);
-	ucontrol->value.integer.value[0] = wm_get(ice, WM_ADC_MUX) & 0x1f;
+	ucontrol->value.enumerated.item[0] = wm_get(ice, WM_ADC_MUX) & 0x1f;
 	mutex_unlock(&ice->gpio_mutex);
 	return 0;
 }
@@ -550,7 +550,7 @@ static int wm_adc_mux_enum_put(struct snd_kcontrol *kcontrol,
 
 	mutex_lock(&ice->gpio_mutex);
 	oval = wm_get(ice, WM_ADC_MUX);
-	nval = (oval & 0xe0) | ucontrol->value.integer.value[0];
+	nval = (oval & 0xe0) | ucontrol->value.enumerated.item[0];
 	if (nval != oval) {
 		wm_put(ice, WM_ADC_MUX, nval);
 		change = 1;
-- 
2.25.0


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

* Re: [PATCH 0/2] ALSA: Fix for bad ctl access patterns
  2020-04-07  8:44 [PATCH 0/2] ALSA: Fix for bad ctl access patterns Takashi Iwai
  2020-04-07  8:44 ` [PATCH 1/2] ALSA: hda: Fix potential access overflow in beep helper Takashi Iwai
  2020-04-07  8:44 ` [PATCH 2/2] ALSA: ice1724: Fix invalid access for enumerated ctl items Takashi Iwai
@ 2020-04-07 14:30 ` Jaroslav Kysela
  2 siblings, 0 replies; 4+ messages in thread
From: Jaroslav Kysela @ 2020-04-07 14:30 UTC (permalink / raw)
  To: Takashi Iwai, alsa-devel

Dne 07. 04. 20 v 10:44 Takashi Iwai napsal(a):
> Hi,
> 
> the recently introduced ctl access validator succeessfully caught some
> real issues.  Here are some fixes.

Thanks Takashi for the fixes. For both

Reviewed-by: Jaroslav Kysela <perex@perex.cz>

> 
> 
> Takashi
> 
> ===
> 
> Takashi Iwai (2):
>    ALSA: hda: Fix potential access overflow in beep helper
>    ALSA: ice1724: Fix invalid access for enumerated ctl items
> 
>   sound/pci/hda/hda_beep.c         | 6 +++++-
>   sound/pci/ice1712/prodigy_hifi.c | 4 ++--
>   2 files changed, 7 insertions(+), 3 deletions(-)
> 


-- 
Jaroslav Kysela <perex@perex.cz>
Linux Sound Maintainer; ALSA Project; Red Hat, Inc.

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

end of thread, other threads:[~2020-04-07 14:32 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-07  8:44 [PATCH 0/2] ALSA: Fix for bad ctl access patterns Takashi Iwai
2020-04-07  8:44 ` [PATCH 1/2] ALSA: hda: Fix potential access overflow in beep helper Takashi Iwai
2020-04-07  8:44 ` [PATCH 2/2] ALSA: ice1724: Fix invalid access for enumerated ctl items Takashi Iwai
2020-04-07 14:30 ` [PATCH 0/2] ALSA: Fix for bad ctl access patterns Jaroslav Kysela

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.