diff options
| author | Takashi Iwai <tiwai@suse.de> | 2026-08-06 17:32:23 +0200 |
|---|---|---|
| committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2026-09-07 17:18:22 +0200 |
| commit | 0ce391090809d610647f424b9b1dc24aa2c546fd (patch) | |
| tree | c965165c82b98a10fb7a61711f88238d6535e1bb | |
| parent | c069b3cfd753d6688ea0271c43553631ab38ce10 (diff) | |
| download | linux-stable-0ce391090809d610647f424b9b1dc24aa2c546fd.tar.gz linux-stable-0ce391090809d610647f424b9b1dc24aa2c546fd.zip | |
ALSA: portman2x4: Check card index validity at probe
commit 3690ef20469d5959378260e2752f2314a2572913 upstream.
Although portman2x4 driver has a check of the given devptr->id value,
it doesn't check for a negative id, which is often given as "none" or
such value when bound via sysfs. This may lead 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-7-tiwai@suse.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
| -rw-r--r-- | sound/drivers/portman2x4.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/sound/drivers/portman2x4.c b/sound/drivers/portman2x4.c index 54d818d2f53d..642524ae80ba 100644 --- a/sound/drivers/portman2x4.c +++ b/sound/drivers/portman2x4.c @@ -703,6 +703,12 @@ static int snd_portman_probe(struct platform_device *pdev) p = platform_get_drvdata(pdev); platform_set_drvdata(pdev, NULL); + if (dev < 0) { + dev_warn(&pdev->dev, + "Invalid card index %d, using default 0\n", dev); + dev = 0; + } + if (dev >= SNDRV_CARDS) return -ENODEV; if (!enable[dev]) |
