5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <redacted>
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: <redacted>
Signed-off-by: Takashi Iwai <redacted>
Link: https://patch.msgid.link/20260806153227.1460166-7-tiwai@suse.de (local)
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
sound/drivers/portman2x4.c | 6 ++++++
1 file changed, 6 insertions(+)
--- a/sound/drivers/portman2x4.c
+++ b/sound/drivers/portman2x4.c
@@ -715,6 +715,12 @@ static int snd_portman_probe(struct plat
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])