]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
torture: Avoid modulo-zero error in torture_hrtimeout_ns()
authorPaul E. McKenney <paulmck@kernel.org>
Wed, 4 Mar 2026 23:40:39 +0000 (15:40 -0800)
committerJoel Fernandes <joelagnelf@nvidia.com>
Mon, 30 Mar 2026 19:48:14 +0000 (15:48 -0400)
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 <joelagnelf@nvidia.com>
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
Signed-off-by: Joel Fernandes <joelagnelf@nvidia.com>
kernel/torture.c

index ec33709869766599fcf709ca982d4de7c07c0f3c..62c1ac77769424a515295994a8f0b5262a4e2066 100644 (file)
@@ -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);