diff options
| author | Takashi Iwai <tiwai@suse.de> | 2026-08-06 17:32:18 +0200 |
|---|---|---|
| committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2026-09-07 17:18:22 +0200 |
| commit | c589aeaadfde1cfedb5c6f0a3c782807282126d9 (patch) | |
| tree | e9e8ae239d394c0be2b7cf27c67d4e7b5b3f5a8c | |
| parent | 466e911bbbbb779bb06337e35a286e5ca7af16b3 (diff) | |
| download | linux-c589aeaadfde1cfedb5c6f0a3c782807282126d9.tar.gz linux-c589aeaadfde1cfedb5c6f0a3c782807282126d9.zip | |
ALSA: aloop: Check card index validity at probe
commit 819b106a9fd2ef3fd8abf898b9a8e4524eca8f48 upstream.
aloop 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-2-tiwai@suse.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
| -rw-r--r-- | sound/drivers/aloop.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/sound/drivers/aloop.c b/sound/drivers/aloop.c index a71e74d496b0..bb75051be5ee 100644 --- a/sound/drivers/aloop.c +++ b/sound/drivers/aloop.c @@ -1822,6 +1822,12 @@ static int loopback_probe(struct platform_device *devptr) int dev = devptr->id; int err; + if (dev < 0 || dev >= SNDRV_CARDS) { + dev_warn(&devptr->dev, + "Invalid card index %d, using default 0\n", dev); + dev = 0; + } + err = snd_devm_card_new(&devptr->dev, index[dev], id[dev], THIS_MODULE, sizeof(struct loopback), &card); if (err < 0) |
