]> git.baikalelectronics.ru Git - kernel.git/commit
timerqueue: Use rb_entry_safe() in timerqueue_getnext()
authorBarnabás Pőcze <pobrn@protonmail.com>
Mon, 14 Nov 2022 19:54:23 +0000 (19:54 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 18 Jan 2023 10:40:53 +0000 (11:40 +0100)
commit437eb54334e08983c548337b7c2d1512ddbe9e2f
treeee41da1b01fd761d1cac864e69d47cc7a02357e7
parentcf1ac4c079a36d57785b990aa84069b0ad65be03
timerqueue: Use rb_entry_safe() in timerqueue_getnext()

[ Upstream commit 88cf5d794a2a7dfff3790e271f33f2cf5a4f1d69 ]

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.

Fixes: 27060385dd50 ("lib/timerqueue: Rely on rbtree semantics for next timer")
Signed-off-by: Barnabás Pőcze <pobrn@protonmail.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Link: https://lore.kernel.org/r/20221114195421.342929-1-pobrn@protonmail.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
include/linux/timerqueue.h