mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-10-06 08:46:46 +00:00
staging: comedi: addi_apci_3xxx: check return value
Function pci_ioremap_bar() will return a NULL pointer if there is no enough memory. However, in function apci3xxx_auto_attach(), the return value of function pci_ioremap_bar() is not validated. This may result in NULL dereference in following access to dev->mmio. This patch fixes the bug. Signed-off-by: Pan Bian <bianpan2016@163.com> Reviewed-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
255364f7b8
commit
a455178e59
1 changed files with 2 additions and 0 deletions
|
@ -787,6 +787,8 @@ static int apci3xxx_auto_attach(struct comedi_device *dev,
|
||||||
|
|
||||||
dev->iobase = pci_resource_start(pcidev, 2);
|
dev->iobase = pci_resource_start(pcidev, 2);
|
||||||
dev->mmio = pci_ioremap_bar(pcidev, 3);
|
dev->mmio = pci_ioremap_bar(pcidev, 3);
|
||||||
|
if (!dev->mmio)
|
||||||
|
return -ENOMEM;
|
||||||
|
|
||||||
if (pcidev->irq > 0) {
|
if (pcidev->irq > 0) {
|
||||||
ret = request_irq(pcidev->irq, apci3xxx_irq_handler,
|
ret = request_irq(pcidev->irq, apci3xxx_irq_handler,
|
||||||
|
|
Loading…
Reference in a new issue