Re: [PATCH v3] staging: most: dim2: fix race condition in network info delivery
From: Dan Carpenter
Date: Thu Mar 19 2026 - 04:24:02 EST
On Thu, Mar 19, 2026 at 01:49:06AM +0900, Minu Jin wrote:
> The previous implementation could lead to race conditions between
> deliver_netinfo_thread() and retrieve_netinfo().
> Additionally, multiple interrupts could lead to event loss.
>
> 1. Using local variables to store a snapshot of the network
> information under a spinlock. This prevents race conditions between
> deliver_netinfo_thread() and retrieve_netinfo().
>
> 2. Invoking the on_netinfo() callback outside the spinlock. Since
> callbacks may sleep or take other locks, it must be called after
> releasing the spinlock, using the previously captured local variables.
>
> 3. Introducing an 'is_netinfo_pending' flag to track the delivery
> status. This avoids redundant wake-ups of the delivery
> thread when multiple interrupts occur.
>
> Fixes: ba3d7ddfb5c6 ("Staging: most: add MOST driver's hdm-dim2 module")
> Signed-off-by: Minu Jin <s9430939@xxxxxxxxx>
> ---
> Changes in v3:
> - No code chages: resend to include missing mailing lists.
>
> Changes in v2:
> - Add 'is_netinfo_pending' flag to prevent redundant wake-ups.
> - Add Fixes tag.
>
> Test Note:
> - Compiled success, with no error.
> - Verified with Smatch, no new warnings.
>
I had really hoped this was tested... It's difficult to know just
from looking at it if it's correct. We could add a FIXME in the
code:
/* FIXME: This is racy. See:
* https://lore.kernel.org/all/20260318164906.262225-1-s9430939@xxxxxxxxx/
*/
We wouldn't need is_netinfo_pending because we already have
dev->deliver_netinfo. But I'm not sure that this patch is correct.
Probably it's less correct than the current behavior which will
eventually set it to the right thing even if it goes through a corrupted
step first.
regards,
dan carpenter