summaryrefslogtreecommitdiffstats
path: root/sound/soc
diff options
context:
space:
mode:
authorVenkata Prasad Potturu <venkataprasad.potturu@amd.com>2022-07-21 11:50:37 +0530
committerMark Brown <broonie@kernel.org>2022-07-21 23:24:15 +0100
commitc49f5e74a11e3909c424cada0f5d52345084933f (patch)
treed8ee88d48fa73c08c66ed6f8c7d2d5569b584930 /sound/soc
parent96b008a1c2e9f455d982e9cfb7117a3a0fc8f550 (diff)
downloadlinux-stable-c49f5e74a11e3909c424cada0f5d52345084933f.tar.gz
linux-stable-c49f5e74a11e3909c424cada0f5d52345084933f.tar.bz2
linux-stable-c49f5e74a11e3909c424cada0f5d52345084933f.zip
ASoC: amd: acp: Add error handling cases
Add error handling in acp pci driver probe function. Signed-off-by: Venkata Prasad Potturu <venkataprasad.potturu@amd.com> Reviewed-by: Vijendar Mukunda <Vijendar.Mukunda@amd.com> Link: https://lore.kernel.org/r/20220721062043.3016985-5-venkataprasad.potturu@amd.com Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'sound/soc')
-rw-r--r--sound/soc/amd/acp/acp-pci.c24
1 files changed, 20 insertions, 4 deletions
diff --git a/sound/soc/amd/acp/acp-pci.c b/sound/soc/amd/acp/acp-pci.c
index 34d75603eea1..2c8e960cc9a6 100644
--- a/sound/soc/amd/acp/acp-pci.c
+++ b/sound/soc/amd/acp/acp-pci.c
@@ -70,7 +70,8 @@ static int acp_pci_probe(struct pci_dev *pci, const struct pci_device_id *pci_id
ret = pci_request_regions(pci, "AMD ACP3x audio");
if (ret < 0) {
dev_err(&pci->dev, "pci_request_regions failed\n");
- return -ENOMEM;
+ ret = -ENOMEM;
+ goto disable_pci;
}
pci_set_master(pci);
@@ -89,22 +90,29 @@ static int acp_pci_probe(struct pci_dev *pci, const struct pci_device_id *pci_id
break;
default:
dev_err(dev, "Unsupported device revision:0x%x\n", pci->revision);
- return -EINVAL;
+ ret = -EINVAL;
+ goto release_regions;
}
dmic_dev = platform_device_register_data(dev, "dmic-codec", PLATFORM_DEVID_NONE, NULL, 0);
if (IS_ERR(dmic_dev)) {
dev_err(dev, "failed to create DMIC device\n");
- return PTR_ERR(dmic_dev);
+ ret = PTR_ERR(dmic_dev);
+ goto release_regions;
}
addr = pci_resource_start(pci, 0);
chip->base = devm_ioremap(&pci->dev, addr, pci_resource_len(pci, 0));
+ if (!chip->base) {
+ ret = -ENOMEM;
+ goto release_regions;
+ }
res = devm_kzalloc(&pci->dev, sizeof(struct resource) * num_res, GFP_KERNEL);
if (!res) {
platform_device_unregister(dmic_dev);
- return -ENOMEM;
+ ret = -ENOMEM;
+ goto release_regions;
}
for (i = 0; i < num_res; i++, res_acp++) {
@@ -133,9 +141,17 @@ static int acp_pci_probe(struct pci_dev *pci, const struct pci_device_id *pci_id
dev_err(&pci->dev, "cannot register %s device\n", pdevinfo.name);
platform_device_unregister(dmic_dev);
ret = PTR_ERR(pdev);
+ goto release_regions;
}
return ret;
+
+release_regions:
+ pci_release_regions(pci);
+disable_pci:
+ pci_disable_device(pci);
+
+ return ret;
};
static void acp_pci_remove(struct pci_dev *pci)