hrtimer: Prevent queuing of hrtimer without a function callback

The hrtimer function callback must not be NULL. It has to be specified by
the call side but it is not validated by the hrtimer code. When a hrtimer
is queued without a function callback, the kernel crashes with a null
pointer dereference when trying to execute the callback in __run_hrtimer().

Introduce a validation before queuing the hrtimer in
hrtimer_start_range_ns().

[anna-maria: Rephrase commit message]

Signed-off-by: Phil Chang <phil.chang@mediatek.com>
Signed-off-by: Anna-Maria Behnsen <anna-maria@linutronix.de>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Anna-Maria Behnsen <anna-maria@linutronix.de>

authored by Phil Chang and committed by Thomas Gleixner 5a830bbc 6ba59ff4

+2
+2
kernel/time/hrtimer.c
··· 1285 1285 struct hrtimer_clock_base *base; 1286 1286 unsigned long flags; 1287 1287 1288 + if (WARN_ON_ONCE(!timer->function)) 1289 + return; 1288 1290 /* 1289 1291 * Check whether the HRTIMER_MODE_SOFT bit and hrtimer.is_soft 1290 1292 * match on CONFIG_PREEMPT_RT = n. With PREEMPT_RT check the hard