lkml.org 
[lkml]   [2019]   [Jun]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] PCI/hotplug: fix potential null pointer deference
Date
There is otherwise a risk of a null pointer dereference.

Signed-off-by: Young Xiao <92siuyang@gmail.com>
---
drivers/pci/hotplug/cpqphp_ctrl.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/pci/hotplug/cpqphp_ctrl.c b/drivers/pci/hotplug/cpqphp_ctrl.c
index b7f4e1f..3c8399f 100644
--- a/drivers/pci/hotplug/cpqphp_ctrl.c
+++ b/drivers/pci/hotplug/cpqphp_ctrl.c
@@ -598,10 +598,11 @@ static struct pci_resource *get_io_resource(struct pci_resource **head, u32 size
*head = node->next;
} else {
prevnode = *head;
- while (prevnode->next != node)
+ while (prevnode && prevnode->next != node)
prevnode = prevnode->next;

- prevnode->next = node->next;
+ if (prevnode)
+ prevnode->next = node->next;
}
node->next = NULL;
break;
@@ -788,10 +789,11 @@ static struct pci_resource *get_resource(struct pci_resource **head, u32 size)
*head = node->next;
} else {
prevnode = *head;
- while (prevnode->next != node)
+ while (prevnode && prevnode->next != node)
prevnode = prevnode->next;

- prevnode->next = node->next;
+ if (prevnode)
+ prevnode->next = node->next;
}
node->next = NULL;
break;
--
2.7.4
\
 
 \ /
  Last update: 2019-06-14 14:40    [W:0.072 / U:0.432 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site