summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2026-08-06 17:32:19 +0200
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2026-09-07 17:18:22 +0200
commit76b6bc38d0f310c0ae1b2a2ebabe2947d92c601a (patch)
tree7a1018435bd6a2fe5fa0160cdf9e7cde2cbd6910
parenteb482a06791d6168beb8c78cc904ac5a5ed96a55 (diff)
downloadlinux-stable-76b6bc38d0f310c0ae1b2a2ebabe2947d92c601a.tar.gz
linux-stable-76b6bc38d0f310c0ae1b2a2ebabe2947d92c601a.zip
ALSA: mpu401: Check card index validity at probe
commit f7dcecb92ed192ff5fcf842918fb1aaea84b5bdd upstream. mpu401 driver blindly trusts that the given devptr->id value is within the proper card index range at probe. It's OK for the devices the driver itself creates at the module probe time, but if the device is bound manually via sysfs interface, this could be -1 as "none", and this leads to OOB access for index[] and other parameters. Add a sanity check for the card index and warn/correct it if it's a value out of the range. Cc: stable@vger.kernel.org Signed-off-by: Takashi Iwai <tiwai@suse.de> Link: https://patch.msgid.link/20260806153227.1460166-3-tiwai@suse.de Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--sound/drivers/mpu401/mpu401.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/sound/drivers/mpu401/mpu401.c b/sound/drivers/mpu401/mpu401.c
index cd01af5fa4ed..d1194e9682b9 100644
--- a/sound/drivers/mpu401/mpu401.c
+++ b/sound/drivers/mpu401/mpu401.c
@@ -89,6 +89,12 @@ static int snd_mpu401_probe(struct platform_device *devptr)
int err;
struct snd_card *card;
+ if (dev < 0 || dev >= SNDRV_CARDS) {
+ dev_warn(&devptr->dev,
+ "Invalid card index %d, using default 0\n", dev);
+ dev = 0;
+ }
+
if (port[dev] == SNDRV_AUTO_PORT) {
dev_err(&devptr->dev, "specify port\n");
return -EINVAL;