Message ID | 20220426183357.102155-1-pierre-louis.bossart@linux.intel.com |
---|---|
State | New |
Headers | show |
Series | ASoC: SOF: Fix NULL pointer exception in sof_pci_probe callback | expand |
On Tue, 26 Apr 2022 13:33:57 -0500, Pierre-Louis Bossart wrote: > From: Ajit Kumar Pandey <AjitKumar.Pandey@amd.com> > > We are accessing "desc->ops" in sof_pci_probe without checking "desc" > pointer. This results in NULL pointer exception if pci_id->driver_data > i.e desc pointer isn't defined in sof device probe: > > BUG: kernel NULL pointer dereference, address: 0000000000000060 > PGD 0 P4D 0 > Oops: 0000 [#1] PREEMPT SMP NOPTI > RIP: 0010:sof_pci_probe+0x1e/0x17f [snd_sof_pci] > Code: Unable to access opcode bytes at RIP 0xffffffffc043dff4. > RSP: 0018:ffffac4b03b9b8d8 EFLAGS: 00010246 > > [...] Applied to https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next Thanks! [1/1] ASoC: SOF: Fix NULL pointer exception in sof_pci_probe callback commit: c61711c1c95791850be48dd65a1d72eb34ba719f All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted. You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed. If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced. Please add any relevant lists and maintainers to the CCs when replying to this mail. Thanks, Mark
diff --git a/sound/soc/sof/sof-pci-dev.c b/sound/soc/sof/sof-pci-dev.c index cd90da7c92c24..8fe8f75446787 100644 --- a/sound/soc/sof/sof-pci-dev.c +++ b/sound/soc/sof/sof-pci-dev.c @@ -187,6 +187,11 @@ int sof_pci_probe(struct pci_dev *pci, const struct pci_device_id *pci_id) dev_dbg(&pci->dev, "PCI DSP detected"); + if (!desc) { + dev_err(dev, "error: no matching PCI descriptor\n"); + return -ENODEV; + } + if (!desc->ops) { dev_err(dev, "error: no matching PCI descriptor ops\n"); return -ENODEV;