Skip to content

Commit

Permalink
ASoC: SOF: Intel: Check the bar size before remapping
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
ZheyuMa authored and broonie committed Apr 13, 2022
1 parent 90b76a3 commit 5947b27
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion sound/soc/sof/intel/pci-tng.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 5947b27

Please sign in to comment.