summaryrefslogtreecommitdiff
path: root/sound/soc/sof/intel
diff options
context:
space:
mode:
authorZheyu Ma <zheyuma97@gmail.com>2022-04-09 22:39:50 +0800
committerMark Brown <broonie@kernel.org>2022-04-13 13:47:40 +0100
commit5947b2726beb61fe7911580f239222ec9c4f6967 (patch)
treedb2533841b67624d940c8908ed6f4b47fff8bf02 /sound/soc/sof/intel
parent90b76a3cb9bf208286851560cfc70830c91c1d3f (diff)
downloadlwn-5947b2726beb61fe7911580f239222ec9c4f6967.tar.gz
lwn-5947b2726beb61fe7911580f239222ec9c4f6967.zip
ASoC: SOF: Intel: Check the bar size before remapping
The driver should use the pci_resource_len() to get the actual length of pci bar, and compare it with the expect value. If the bar size is too small (such as a broken device), the driver should return an error. Signed-off-by: Zheyu Ma <zheyuma97@gmail.com> Link: https://lore.kernel.org/r/20220409143950.2570186-1-zheyuma97@gmail.com Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'sound/soc/sof/intel')
-rw-r--r--sound/soc/sof/intel/pci-tng.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/sound/soc/sof/intel/pci-tng.c b/sound/soc/sof/intel/pci-tng.c
index 6efef225973f..7d502cc3ca80 100644
--- a/sound/soc/sof/intel/pci-tng.c
+++ b/sound/soc/sof/intel/pci-tng.c
@@ -75,7 +75,11 @@ static int tangier_pci_probe(struct snd_sof_dev *sdev)
/* LPE base */
base = pci_resource_start(pci, desc->resindex_lpe_base) - IRAM_OFFSET;
- size = PCI_BAR_SIZE;
+ size = pci_resource_len(pci, desc->resindex_lpe_base);
+ if (size < PCI_BAR_SIZE) {
+ dev_err(sdev->dev, "error: I/O region is too small.\n");
+ return -ENODEV;
+ }
dev_dbg(sdev->dev, "LPE PHY base at 0x%x size 0x%x", base, size);
sdev->bar[DSP_BAR] = devm_ioremap(sdev->dev, base, size);