Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Pan Bian and committed by
Greg Kroah-Hartman
a455178e 255364f7

+2
+2
drivers/staging/comedi/drivers/addi_apci_3xxx.c
··· 787 787 788 788 dev->iobase = pci_resource_start(pcidev, 2); 789 789 dev->mmio = pci_ioremap_bar(pcidev, 3); 790 + if (!dev->mmio) 791 + return -ENOMEM; 790 792 791 793 if (pcidev->irq > 0) { 792 794 ret = request_irq(pcidev->irq, apci3xxx_irq_handler,