public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@linaro.org>
To: Minu Jin <s9430939@naver.com>
Cc: parthiban.veerasooran@microchip.com,
	christian.gromm@microchip.com, gregkh@linuxfoundation.org,
	kees@kernel.org, ethantidmore06@gmail.com,
	linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3] staging: most: dim2: fix race condition in network info delivery
Date: Thu, 19 Mar 2026 11:18:53 +0300	[thread overview]
Message-ID: <abuxbTrdWgKPvZ4F@stanley.mountain> (raw)
In-Reply-To: <20260318164906.262225-1-s9430939@naver.com>

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@naver.com>
> ---
> 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@naver.com/
	 */

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


      reply	other threads:[~2026-03-19  8:18 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-18 16:49 [PATCH v3] staging: most: dim2: fix race condition in network info delivery Minu Jin
2026-03-19  8:18 ` Dan Carpenter [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=abuxbTrdWgKPvZ4F@stanley.mountain \
    --to=dan.carpenter@linaro.org \
    --cc=christian.gromm@microchip.com \
    --cc=ethantidmore06@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=kees@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-staging@lists.linux.dev \
    --cc=parthiban.veerasooran@microchip.com \
    --cc=s9430939@naver.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox