]> git.baikalelectronics.ru Git - kernel.git/commit
ALSA: off by one bug in snd_riptide_joystick_probe()
authorDan Carpenter <dan.carpenter@oracle.com>
Mon, 9 Feb 2015 13:51:40 +0000 (16:51 +0300)
committerTakashi Iwai <tiwai@suse.de>
Mon, 9 Feb 2015 13:57:15 +0000 (14:57 +0100)
commit4b5f19ff703b4f3891e41f848c8055ab34864a4b
treed230cc342be6f3b28138351eae7025d6b60404fe
parent7a49a54b6a3eb6047f4e2e33cbb5938300964b34
ALSA: off by one bug in snd_riptide_joystick_probe()

The problem here is that we check:

if (dev >= SNDRV_CARDS)

Then we increment "dev".

       if (!joystick_port[dev++])

Then we use it as an offset into a array with SNDRV_CARDS elements.

if (!request_region(joystick_port[dev], 8, "Riptide gameport")) {

This has 3 effects:
1) If you use the module option to specify the joystick port then it has
   to be shifted one space over.
2) The wrong error message will be printed on failure if you have over
   32 cards.
3) Static checkers will correctly complain that are off by one.

Fixes: ae4fb4d4e96d ('ALSA: riptide - Fix joystick resource handling')
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/pci/riptide/riptide.c