From: Paul E. McKenney Date: Wed, 4 Mar 2026 23:40:39 +0000 (-0800) Subject: torture: Avoid modulo-zero error in torture_hrtimeout_ns() X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=a18396219ba52b524d8b86bf9e2515b01c068614;p=thirdparty%2Flinux.git torture: Avoid modulo-zero error in torture_hrtimeout_ns() Currently, all calls to torture_hrtimeout_ns() either provide a non-zero fuzzt_ns or a NULL trsp, either of which avoids taking the modulus of a zero-valued fuzzt_ns. But this code should do a better job of defending itself, so this commit explicitly checks fuzzt_ns and avoids the modulus when its value is zero. Reviewed-by: Joel Fernandes Signed-off-by: Paul E. McKenney Signed-off-by: Joel Fernandes --- diff --git a/kernel/torture.c b/kernel/torture.c index ec33709869766..62c1ac7776942 100644 --- a/kernel/torture.c +++ b/kernel/torture.c @@ -93,7 +93,7 @@ int torture_hrtimeout_ns(ktime_t baset_ns, u32 fuzzt_ns, const enum hrtimer_mode { ktime_t hto = baset_ns; - if (trsp) + if (trsp && fuzzt_ns) hto += torture_random(trsp) % fuzzt_ns; set_current_state(TASK_IDLE); return schedule_hrtimeout(&hto, mode);