PCI: cpqphp: Fix possible null pointer dereference
authorRickard Strandqvist <rickard_strandqvist@spectrumdigital.se>
Sun, 18 May 2014 16:02:57 +0000 (18:02 +0200)
committerBjorn Helgaas <bhelgaas@google.com>
Wed, 28 May 2014 02:51:14 +0000 (20:51 -0600)
There is otherwise a risk of a null pointer dereference.

Found by cppcheck, a static code analysis program.

Signed-off-by: Rickard Strandqvist <rickard_strandqvist@spectrumdigital.se>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
drivers/pci/hotplug/cpqphp_ctrl.c

index 11845b7967995479d5fab311f0a6f4c53fb4a97f..f593585f2784db118b2a944154e5714f9acf7fab 100644 (file)
@@ -709,7 +709,8 @@ static struct pci_resource *get_max_resource(struct pci_resource **head, u32 siz
                                temp = temp->next;
                        }
 
-                       temp->next = max->next;
+                       if (temp)
+                               temp->next = max->next;
                }
 
                max->next = NULL;