Re: [PATCH v1] timerqueue: use rb_entry_safe() in timerqueue_getnext()

From: Thomas Gleixner
Date: Mon Nov 14 2022 - 14:16:39 EST


On Mon, Nov 14 2022 at 15:54, Barnabás Pőcze wrote:
> 2022. november 14., hétfő 1:17 keltezéssel, Thomas Gleixner írta:
>> On Thu, Oct 27 2022 at 21:37, Barnabás Pőcze wrote:
>
> 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.

Yes. Very precise and informative.

>> Back then when that code got introduced rb_entry_safe() did not exist at
>> all so it's even more obvious that this is simply a missing NULL pointer
>> check, right?
>
> As far as I can tell it did exist and it was actually used
> when the offending change was committed (511885d7061e).

Hmm. I must have messed up when searching in the history.

Thanks,

tglx