mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jiri Slaby <jirislaby@kernel.org>
To: Johan Hovold <johan@kernel.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org,
	stable@vger.kernel.org
Subject: Re: [PATCH v3 1/4] serial: revert guards in uart_wait_modem_status()
Date: Mon, 7 Sep 2026 08:47:45 +0200	[thread overview]
Message-ID: <3f33d9f0-65c2-49b7-bb6d-2fe33f0d8fbe@kernel.org> (raw)
In-Reply-To: <20260907064418.92953-2-johan@kernel.org>

On 07. 09. 26, 8:44, Johan Hovold wrote:
> Mixing scope-based and regular cleanup is discouraged and
> uart_port_deref() used by uart_wait_modem_status() falls in the latter
> category.
> 
> Revert the premature guard conversion in preparation for fixing a hangup
> race.

It's not premature. Just convert uart_port_ref() to guards too. Gotos suck.

> Fixes: 56609c050051 ("serial: serial_core: use guard()s")
> Cc: stable@vger.kernel.org	# 6.18
> Cc: Jiri Slaby (SUSE) <jirislaby@kernel.org>
> Signed-off-by: Johan Hovold <johan@kernel.org>
> ---
>   drivers/tty/serial/serial_core.c | 13 +++++++------
>   1 file changed, 7 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
> index 95774b0f1484..1553bc6cbe7b 100644
> --- a/drivers/tty/serial/serial_core.c
> +++ b/drivers/tty/serial/serial_core.c
> @@ -1213,15 +1213,16 @@ static int uart_wait_modem_status(struct uart_state *state, unsigned long arg)
>   	uport = uart_port_ref(state);
>   	if (!uport)
>   		return -EIO;
> -	scoped_guard(uart_port_lock_irq, uport) {
> -		memcpy(&cprev, &uport->icount, sizeof(struct uart_icount));
> -		uart_enable_ms(uport);
> -	}
> +	uart_port_lock_irq(uport);
> +	memcpy(&cprev, &uport->icount, sizeof(struct uart_icount));
> +	uart_enable_ms(uport);
> +	uart_port_unlock_irq(uport);
>   
>   	add_wait_queue(&port->delta_msr_wait, &wait);
>   	for (;;) {
> -		scoped_guard(uart_port_lock_irq, uport)
> -			memcpy(&cnow, &uport->icount, sizeof(struct uart_icount));
> +		uart_port_lock_irq(uport);
> +		memcpy(&cnow, &uport->icount, sizeof(struct uart_icount));
> +		uart_port_unlock_irq(uport);
>   
>   		set_current_state(TASK_INTERRUPTIBLE);
>   


-- 
js
suse labs

  reply	other threads:[~2026-09-07  6:47 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-07  6:44 [PATCH v3 0/4] serial: fix ioctl hangup race Johan Hovold
2026-09-07  6:44 ` [PATCH v3 1/4] serial: revert guards in uart_wait_modem_status() Johan Hovold
2026-09-07  6:47   ` Jiri Slaby [this message]
2026-09-07  6:51     ` Jiri Slaby
2026-09-07  7:37       ` Johan Hovold
2026-09-07  6:44 ` [PATCH v3 2/4] serial: fix ioctl hangup race Johan Hovold
2026-09-07  6:44 ` [PATCH v3 3/4] serial: fix TIOCMIWAIT race Johan Hovold
2026-09-07  6:44 ` [PATCH v3 4/4] serial: abort TIOCMIWAIT on hangup Johan Hovold

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=3f33d9f0-65c2-49b7-bb6d-2fe33f0d8fbe@kernel.org \
    --to=jirislaby@kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=johan@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-serial@vger.kernel.org \
    --cc=stable@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®