Re: [RFC PATCH] usb_wwan : add locking around shared port data in two FIXME-marked places
From: Oliver Neukum
Date: Tue Jun 24 2025 - 04:02:21 EST
Hi,
On 20.06.25 12:17, Abinash Singh wrote:
Fix two locking-related FIXME comments by adding a mutex
to protect shared fields in `usb_wwan_port_private`.
- In `usb_wwan_dtr_rts()`, access to `rts_state`
and `dtr_state` is now protected by `portdata->lock`.
- In `usb_wwan_tiocmset()`, access to `rts_state`
and `dtr_state` is now also synchronized with the same mutex.
These changes prevent possible data races
and inconsistent state updates when the port is written concurrently.
unfortunately this patch is rather problematic because
1. you never initialize the mutex
2. these values are read in usb_wwan_send_setup(), where you don't take the lock
Now, as usb_wwan_send_setup() is called right after you drop
the mutex, this patch is kind of inelegant.
Sorry
Oliver