Re: [PATCH v2] hrtimer: check hrtimer with a NULL function
From: Anna-Maria Behnsen <anna-maria@linutronix.de>
Date: 2024-06-10 09:47:43
Also in:
lkml
Phil Chang [off-list ref] writes:
Since hrtimers do not allow a NULL function to be passed, to prevent a kernel crash, return before adding the timer to a queue.
You could point out in the commit message, where the kernel would crash when using a hrtimer with a NULL pointer as function pointer. And it shouldn't be a problem to use more than a single sentence for a commit message :)
quoted hunk ↗ jump to hunk
Signed-off-by: Phil Chang <redacted> --- kernel/time/hrtimer.c | 3 +++ 1 file changed, 3 insertions(+)diff --git a/kernel/time/hrtimer.c b/kernel/time/hrtimer.c index 492c14aac642..d32c1afe59b3 100644 --- a/kernel/time/hrtimer.c +++ b/kernel/time/hrtimer.c@@ -1285,6 +1285,9 @@ void hrtimer_start_range_ns(struct hrtimer *timer, ktime_t tim, struct hrtimer_clock_base *base; unsigned long flags; + if (WARN_ON(!timer->function)) + return; +
Please use a WARN_ON_ONCE() (as documented in Documentation/process/coding-style.rst)
/* * Check whether the HRTIMER_MODE_SOFT bit and hrtimer.is_soft * match on CONFIG_PREEMPT_RT = n. With PREEMPT_RT check the hard
Thanks, Anna-Maria _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel