]> git.proxmox.com Git - mirror_ubuntu-focal-kernel.git/commit
ALSA: asihpi: fix iounmap in error handler
authorTom Rix <trix@redhat.com>
Sun, 13 Sep 2020 16:52:30 +0000 (09:52 -0700)
committerStefan Bader <stefan.bader@canonical.com>
Mon, 9 Nov 2020 13:48:01 +0000 (14:48 +0100)
commit73ba24fcb3f8fe23879fca1723fb336f36f03d4e
tree1c92e4bea9fe8804e6ee7bd2c945eb416a882f4f
parentb6fe9a1089d14486fc56d1bb5c60e86812888306
ALSA: asihpi: fix iounmap in error handler

BugLink: https://bugs.launchpad.net/bugs/1900624
[ Upstream commit 472eb39103e885f302fd8fd6eff104fcf5503f1b ]

clang static analysis flags this problem
hpioctl.c:513:7: warning: Branch condition evaluates to
  a garbage value
                if (pci.ap_mem_base[idx]) {
                    ^~~~~~~~~~~~~~~~~~~~

If there is a failure in the middle of the memory space loop,
only some of the memory spaces need to be cleaned up.

At the error handler, idx holds the number of successful
memory spaces mapped.  So rework the handler loop to use the
old idx.

There is a second problem, the memory space loop conditionally
iomaps()/sets the mem_base so it is necessay to initize pci.

Fixes: 719f82d3987a ("ALSA: Add support of AudioScience ASI boards")
Signed-off-by: Tom Rix <trix@redhat.com>
Link: https://lore.kernel.org/r/20200913165230.17166-1-trix@redhat.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: Ian May <ian.may@canonical.com>
sound/pci/asihpi/hpioctl.c