Re: [PATCH] firewire: core: consolidate lock scopes for event waiting in dequeue function
From: Takashi Sakamoto
Date: Sun Sep 20 2026 - 23:02:17 EST
On Sun, Sep 20, 2026 at 07:47:45PM +0900, Takashi Sakamoto wrote:
> Current implementation uses the spinlock in the card structure to
> serialize accesses to the event list. The dequeue_event() function yields
> the CPU while waiting for the condition to become true, but checks the
> list without acquiring the spinlock. It acquires the spinlock when
> operating the list, however it assumes that the list has at least one
> entry.
>
> This can cause problems when multiple threads execute read(2) system calls
> concurrently, since the list can become empty after rescheduling but before
> the list operation, depending on the scheduling order of the two threads.
>
> Use a wait_event variant that reacquires the lock after being
> rescheduled, before checking the condition.
>
> Signed-off-by: Takashi Sakamoto <o-takashi@xxxxxxxxxxxxx>
> ---
> drivers/firewire/core-cdev.c | 26 +++++++++++++++++---------
> 1 file changed, 17 insertions(+), 9 deletions(-)
Applied to for-next branch.
Regards
Takashi Sakamoto