History

timerqueue: Use rb_entry_safe() in timerqueue_getnext()

When `timerqueue_getnext()` is called on an empty timer queue, it will use `rb_entry()` on a NULL pointer, which is invalid. Fix that by using `rb_entry_safe()` which handles NULL pointers. This has not caused any issues so far because the offset of the `rb_node` member in `timerqueue_node` is 0, so `rb_entry()` is essentially a no-op.

Barnabás Pőcze committed 4 years ago

Commit 2f117481 parent 8be3f961 file · +1 −1Browse files

Showing the changes to include/linux/timerqueue.h (1 of 1 file). Show all

Unified · Split

include/linux/timerqueue.h+1−1
@@ -35,7 +35,7 @@ struct timerqueue_node *timerqueue_getnext(struct timerqueue_head *head) · 34 unmodified lines
3535 {
3636 struct rb_node *leftmost = rb_first_cached(&head->rb_root);
3737
38− return rb_entry(leftmost, struct timerqueue_node, node);
38+ return rb_entry_safe(leftmost, struct timerqueue_node, node);
3939 }
4040
4141 static inline void timerqueue_init(struct timerqueue_node *node)

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t