Skip to content

Commit

Permalink
staging: comedi: addi_apci_3xxx: check return value
Browse files Browse the repository at this point in the history
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 <[email protected]>
Reviewed-by: Ian Abbott <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
  • Loading branch information
SinkFinder authored and gregkh committed Apr 25, 2017
1 parent 255364f commit a455178
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions drivers/staging/comedi/drivers/addi_apci_3xxx.c
Original file line number Diff line number Diff line change
Expand Up @@ -787,6 +787,8 @@ static int apci3xxx_auto_attach(struct comedi_device *dev,

dev->iobase = pci_resource_start(pcidev, 2);
dev->mmio = pci_ioremap_bar(pcidev, 3);
if (!dev->mmio)
return -ENOMEM;

if (pcidev->irq > 0) {
ret = request_irq(pcidev->irq, apci3xxx_irq_handler,
Expand Down

0 comments on commit a455178

Please sign in to comment.