]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commit
ALSA: i2c: ak4xxx-adda: Fix a possible null pointer dereference in build_adc_controls()
authorJia-Ju Bai <baijiaju1990@gmail.com>
Fri, 26 Jul 2019 02:14:42 +0000 (10:14 +0800)
committerKleber Sacilotto de Souza <kleber.souza@canonical.com>
Wed, 16 Oct 2019 09:55:21 +0000 (11:55 +0200)
commit6e3b2218f2aee2002735f2b6a0b82bc819ca5de8
tree051b8121f557311e43e5ae35945660586b2456dd
parent1f38625529aa1459f65270ee1cce0775cc637670
ALSA: i2c: ak4xxx-adda: Fix a possible null pointer dereference in build_adc_controls()

BugLink: https://bugs.launchpad.net/bugs/1847155
[ Upstream commit 2127c01b7f63b06a21559f56a8c81a3c6535bd1a ]

In build_adc_controls(), there is an if statement on line 773 to check
whether ak->adc_info is NULL:
    if (! ak->adc_info ||
        ! ak->adc_info[mixer_ch].switch_name)

When ak->adc_info is NULL, it is used on line 792:
    knew.name = ak->adc_info[mixer_ch].selector_name;

Thus, a possible null-pointer dereference may occur.

To fix this bug, referring to lines 773 and 774, ak->adc_info
and ak->adc_info[mixer_ch].selector_name are checked before being used.

This bug is found by a static analysis tool STCheck written by us.

Signed-off-by: Jia-Ju Bai <baijiaju1990@gmail.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
sound/i2c/other/ak4xxx-adda.c