summaryrefslogtreecommitdiffstats
path: root/sound
diff options
context:
space:
mode:
authorTom Rix <trix@redhat.com>2020-09-13 09:52:30 -0700
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2020-10-01 13:14:53 +0200
commitf37ace9a29866ead7785f2c75f70f3840e774540 (patch)
tree37b3830e2d941d5c3402b9875e4295d55ff14ead /sound
parente1a75e94a3acf78e6afdd548a5d504fc29cbc953 (diff)
downloadlinux-stable-f37ace9a29866ead7785f2c75f70f3840e774540.tar.gz
linux-stable-f37ace9a29866ead7785f2c75f70f3840e774540.tar.bz2
linux-stable-f37ace9a29866ead7785f2c75f70f3840e774540.zip
ALSA: asihpi: fix iounmap in error handler
[ 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>
Diffstat (limited to 'sound')
-rw-r--r--sound/pci/asihpi/hpioctl.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/sound/pci/asihpi/hpioctl.c b/sound/pci/asihpi/hpioctl.c
index 7d049569012c..3f06986fbecf 100644
--- a/sound/pci/asihpi/hpioctl.c
+++ b/sound/pci/asihpi/hpioctl.c
@@ -350,7 +350,7 @@ int asihpi_adapter_probe(struct pci_dev *pci_dev,
struct hpi_message hm;
struct hpi_response hr;
struct hpi_adapter adapter;
- struct hpi_pci pci;
+ struct hpi_pci pci = { 0 };
memset(&adapter, 0, sizeof(adapter));
@@ -506,7 +506,7 @@ int asihpi_adapter_probe(struct pci_dev *pci_dev,
return 0;
err:
- for (idx = 0; idx < HPI_MAX_ADAPTER_MEM_SPACES; idx++) {
+ while (--idx >= 0) {
if (pci.ap_mem_base[idx]) {
iounmap(pci.ap_mem_base[idx]);
pci.ap_mem_base[idx] = NULL;