diff mbox series

[v2] arinc653: move next_switch_time access under lock

Message ID b18e523d-89a6-482d-b2ce-a5576578ff58@suse.com (mailing list archive)
State New
Headers show
Series [v2] arinc653: move next_switch_time access under lock | expand

Commit Message

Jan Beulich March 24, 2025, 2:47 p.m. UTC
Even before its recent movement to the scheduler's private data
structure it looks to have been wrong to update the field under lock,
but then read it with the lock no longer held.

Coverity-ID: 1644500
Fixes: 9f0c658baedc ("arinc: add cpu-pool support to scheduler")
Signed-off-by: Jan Beulich <jbeulich@suse.com>
---
The Fixes: tag references where the locking was added; I can't exclude
there was an issue here already before that.
---
v2: Put comment in appropriate place.

Comments

Nathan Studer March 24, 2025, 3:38 p.m. UTC | #1
On 24/03/25 10:47, Jan Beulich wrote:
> Even before its recent movement to the scheduler's private data structure it looks
> to have been wrong to update the field under lock, but then read it with the lock
> no longer held.
> 
> Coverity-ID: 1644500
> Fixes: 9f0c658baedc ("arinc: add cpu-pool support to scheduler")
> Signed-off-by: Jan Beulich <jbeulich@suse.com>
> ---
> The Fixes: tag references where the locking was added; I can't exclude there was
> an issue here already before that.
> ---
> v2: Put comment in appropriate place.
> 

Acked-by: Nathan Studer <nathan.studer@dornerworks.com>
diff mbox series

Patch

--- a/xen/common/sched/arinc653.c
+++ b/xen/common/sched/arinc653.c
@@ -580,6 +580,9 @@  a653sched_do_schedule(
      */
     BUG_ON(now >= sched_priv->next_major_frame);
 
+    /* Return the amount of time the next domain has to run. */
+    prev->next_time = sched_priv->next_switch_time - now;
+
     spin_unlock_irqrestore(&sched_priv->lock, flags);
 
     /* Tasklet work (which runs in idle UNIT context) overrides all else. */
@@ -591,11 +594,7 @@  a653sched_do_schedule(
          && (sched_unit_master(new_task) != cpu) )
         new_task = IDLETASK(cpu);
 
-    /*
-     * Return the amount of time the next domain has to run and the address
-     * of the selected task's UNIT structure.
-     */
-    prev->next_time = sched_priv->next_switch_time - now;
+    /* Also return the address of the selected task's UNIT structure. */
     prev->next_task = new_task;
     new_task->migrated = false;