diff options
| author | Takashi Iwai <tiwai@suse.de> | 2026-08-06 17:32:20 +0200 |
|---|---|---|
| committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2026-09-07 17:18:22 +0200 |
| commit | fbf3fb097e66fc1874e54ecc46d600d9325480d6 (patch) | |
| tree | 089d77524987f2a132131079985bc149bf7b59cd | |
| parent | 0ce391090809d610647f424b9b1dc24aa2c546fd (diff) | |
| download | linux-fbf3fb097e66fc1874e54ecc46d600d9325480d6.tar.gz linux-fbf3fb097e66fc1874e54ecc46d600d9325480d6.zip | |
ALSA: serial-u16550: Check card index validity at probe
commit e0fb960b227fcdebe22e4f26c9486d60943c0424 upstream.
serial-u16550 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-4-tiwai@suse.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
| -rw-r--r-- | sound/drivers/serial-u16550.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/sound/drivers/serial-u16550.c b/sound/drivers/serial-u16550.c index f66e01624c68..05eb811ba7e8 100644 --- a/sound/drivers/serial-u16550.c +++ b/sound/drivers/serial-u16550.c @@ -864,6 +864,12 @@ static int snd_serial_probe(struct platform_device *devptr) int err; int dev = devptr->id; + if (dev < 0 || dev >= SNDRV_CARDS) { + dev_warn(&devptr->dev, + "Invalid card index %d, using default 0\n", dev); + dev = 0; + } + switch (adaptor[dev]) { case SNDRV_SERIAL_SOUNDCANVAS: ins[dev] = 1; |
