mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Oliver Neukum <oneukum@suse.com>
To: Abinash Singh <abinashlalotra@gmail.com>, johan@kernel.org
Cc: gregkh@linuxfoundation.org, linux-usb@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	Abinash Singh <abinashsinghlalotra@gmail.com>
Subject: Re: [RFC PATCH] usb_wwan : add locking around shared port data in two FIXME-marked places
Date: Tue, 24 Jun 2025 10:02:06 +0200	[thread overview]
Message-ID: <f2419bb9-2d81-4a6d-838d-b404e3ce7786@suse.com> (raw)
In-Reply-To: <20250620101747.39037-1-abinashsinghlalotra@gmail.com>

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


  reply	other threads:[~2025-06-24  8:02 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-20 10:17 Abinash Singh
2025-06-24  8:02 ` Oliver Neukum [this message]
2025-06-26 15:31   ` [PATCH] usb: serial: usb_wwan: Fix data races by protecting dtr/rts state with a mutex Abinash Singh
2025-06-28 14:54     ` Greg KH
2025-07-01 21:45       ` [PATCH v2] " Abinash Singh
2025-07-07  8:56         ` Greg KH

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=f2419bb9-2d81-4a6d-838d-b404e3ce7786@suse.com \
    --to=oneukum@suse.com \
    --cc=abinashlalotra@gmail.com \
    --cc=abinashsinghlalotra@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=johan@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    /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

all inboxes | Powered by JetHome®