Skip to content

Commit 5947b27

Browse files
ZheyuMabroonie
authored andcommitted
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>
1 parent 90b76a3 commit 5947b27

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

sound/soc/sof/intel/pci-tng.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,11 @@ static int tangier_pci_probe(struct snd_sof_dev *sdev)
7575

7676
/* LPE base */
7777
base = pci_resource_start(pci, desc->resindex_lpe_base) - IRAM_OFFSET;
78-
size = PCI_BAR_SIZE;
78+
size = pci_resource_len(pci, desc->resindex_lpe_base);
79+
if (size < PCI_BAR_SIZE) {
80+
dev_err(sdev->dev, "error: I/O region is too small.\n");
81+
return -ENODEV;
82+
}
7983

8084
dev_dbg(sdev->dev, "LPE PHY base at 0x%x size 0x%x", base, size);
8185
sdev->bar[DSP_BAR] = devm_ioremap(sdev->dev, base, size);

0 commit comments

Comments
 (0)