From: Shawn Lin Date: Sun, 25 Feb 2018 02:01:42 +0000 (+0800) Subject: PCI: cpqphp: Fix possible NULL pointer dereference X-Git-Tag: v4.19~1271^2~20^2~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=205adda79a408f4a2945f636e1c076f7db3b2045;p=platform%2Fkernel%2Flinux-rpi.git PCI: cpqphp: Fix possible NULL pointer dereference Check io_node for NULL before dereferencing it. Signed-off-by: Shawn Lin Signed-off-by: Bjorn Helgaas --- diff --git a/drivers/pci/hotplug/cpqphp_ctrl.c b/drivers/pci/hotplug/cpqphp_ctrl.c index b1b6e45..616df44 100644 --- a/drivers/pci/hotplug/cpqphp_ctrl.c +++ b/drivers/pci/hotplug/cpqphp_ctrl.c @@ -2812,18 +2812,16 @@ static int configure_new_function(struct controller *ctrl, struct pci_func *func dbg("CND: length = 0x%x\n", base); io_node = get_io_resource(&(resources->io_head), base); + if (!io_node) + return -ENOMEM; dbg("Got io_node start = %8.8x, length = %8.8x next (%p)\n", io_node->base, io_node->length, io_node->next); dbg("func (%p) io_head (%p)\n", func, func->io_head); /* allocate the resource to the board */ - if (io_node) { - base = io_node->base; - - io_node->next = func->io_head; - func->io_head = io_node; - } else - return -ENOMEM; + base = io_node->base; + io_node->next = func->io_head; + func->io_head = io_node; } else if ((temp_register & 0x0BL) == 0x08) { /* Map prefetchable memory */ base = temp_register & 0xFFFFFFF0;