mirror of
https://github.com/torvalds/linux.git
synced 2026-09-14 16:10:02 +02:00
ALSA: serial-u16550: Check card index validity at probe
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
This commit is contained in:
parent
f7dcecb92e
commit
e0fb960b22
|
|
@ -846,6 +846,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;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user