ib mad: fix an incorrect use of list_for_each_entry
In tf_dequeue(), if we reach the end of the list without finding a non-cancelled element, "tmp" will be a pointer into the list head, so the tmp->canceled check is bogus. Use a flag instead. Submitted by: Tao Liu <Tao.Liu@isilon.com> Reviewed by: hselasky MFC after: 1 week Sponsored by: EMC / Isilon Storage Division Differential Revision: https://reviews.freebsd.org/D3244
This commit is contained in:
parent
34996cf7cd
commit
ca7adff0b8
@ -292,6 +292,7 @@ static struct tf_entry *tf_dequeue(struct to_fifo *tf, u32 *time_left_ms)
|
||||
unsigned long flags;
|
||||
unsigned long time_left;
|
||||
struct tf_entry *tmp, *tmp1;
|
||||
bool found = false;
|
||||
|
||||
spin_lock_irqsave(&tf->lists_lock, flags);
|
||||
if (list_empty(&tf->fifo_head)) {
|
||||
@ -300,11 +301,13 @@ static struct tf_entry *tf_dequeue(struct to_fifo *tf, u32 *time_left_ms)
|
||||
}
|
||||
|
||||
list_for_each_entry(tmp, &tf->fifo_head, fifo_list) {
|
||||
if (!tmp->canceled)
|
||||
if (!tmp->canceled) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (tmp->canceled) {
|
||||
if (!found) {
|
||||
spin_unlock_irqrestore(&tf->lists_lock, flags);
|
||||
return NULL;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user