From: Takashi Iwai <tiwai@suse.de>
To: Mark Brown <broonie@kernel.org>
Cc: Hans de Goede <hdegoede@redhat.com>, linux-sound@vger.kernel.org
Subject: [PATCH 3/4] ASoC: Intel: bytcr_rt5651: Avoid OOB array read from the map name
Date: Tue, 15 Apr 2025 10:31:39 +0200 [thread overview]
Message-ID: <20250415083144.6588-4-tiwai@suse.de> (raw)
In-Reply-To: <20250415083144.6588-1-tiwai@suse.de>
Since the quirk bits can be passed arbitrarily via a module option, it
may lead to the OOB access over the map name string array.
Fix it by conditionally reading the array, instead.
Fixes: 64484ccee7af ("ASoC: Intel: bytcr_rt5651: Set card long_name based on quirks")
Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
sound/soc/intel/boards/bytcr_rt5651.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/sound/soc/intel/boards/bytcr_rt5651.c b/sound/soc/intel/boards/bytcr_rt5651.c
index 67c62844ca2a..53f64f01fb22 100644
--- a/sound/soc/intel/boards/bytcr_rt5651.c
+++ b/sound/soc/intel/boards/bytcr_rt5651.c
@@ -881,10 +881,15 @@ struct acpi_chan_package { /* ACPICA seems to require 64 bit integers */
u64 mclock_value; /* usually 25MHz (0x17d7940), ignored */
};
+static const char *mic_name(int n)
+{
+ static const char * const mic_names[] = { "dmic", "in1", "in2", "in12" };
+ return n < ARRAY_SIZE(mic_names) ? mic_names[n] : "none";
+}
+
static int snd_byt_rt5651_mc_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
- static const char * const mic_name[] = { "dmic", "in1", "in2", "in12" };
struct snd_soc_acpi_mach *mach = dev_get_platdata(dev);
struct byt_rt5651_private *priv;
const char *platform_name;
@@ -1071,7 +1076,7 @@ static int snd_byt_rt5651_mc_probe(struct platform_device *pdev)
snprintf(byt_rt5651_components, sizeof(byt_rt5651_components),
"cfg-spk:%s cfg-mic:%s%s",
(byt_rt5651_quirk & BYT_RT5651_MONO_SPEAKER) ? "1" : "2",
- mic_name[BYT_RT5651_MAP(byt_rt5651_quirk)],
+ mic_name(BYT_RT5651_MAP(byt_rt5651_quirk)),
(byt_rt5651_quirk & BYT_RT5651_HP_LR_SWAPPED) ?
" cfg-hp:lrswap" : "");
byt_rt5651_card.components = byt_rt5651_components;
@@ -1080,7 +1085,7 @@ static int snd_byt_rt5651_mc_probe(struct platform_device *pdev)
"bytcr-rt5651-%s-spk-%s-mic%s",
(byt_rt5651_quirk & BYT_RT5651_MONO_SPEAKER) ?
"mono" : "stereo",
- mic_name[BYT_RT5651_MAP(byt_rt5651_quirk)],
+ mic_name(BYT_RT5651_MAP(byt_rt5651_quirk)),
(byt_rt5651_quirk & BYT_RT5651_HP_LR_SWAPPED) ?
"-hp-swapped" : "");
byt_rt5651_card.long_name = byt_rt5651_long_name;
--
2.49.0
next prev parent reply other threads:[~2025-04-15 8:32 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-15 8:31 [PATCH 0/4] ASoC: Intel: byt*: Avoid OOB array read from the map name Takashi Iwai
2025-04-15 8:31 ` [PATCH 1/4] ASoC: Intel: bytcht_es8316: " Takashi Iwai
2025-04-15 8:31 ` [PATCH 2/4] ASoC: Intel: bytcr_rt5640: " Takashi Iwai
2025-04-15 8:31 ` Takashi Iwai [this message]
2025-04-15 8:31 ` [PATCH 4/4] ASoC: Intel: bytcr_wm5102: " Takashi Iwai
2025-04-15 9:12 ` [PATCH 0/4] ASoC: Intel: byt*: " Hans de Goede
2025-04-23 11:47 ` Takashi Iwai
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250415083144.6588-4-tiwai@suse.de \
--to=tiwai@suse.de \
--cc=broonie@kernel.org \
--cc=hdegoede@redhat.com \
--cc=linux-sound@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.