All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Jiri Slaby <jirislaby@kernel.org>,
	linux-serial <linux-serial@vger.kernel.org>,
	Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
	LKML <linux-kernel@vger.kernel.org>,
	Lino Sanfilippo <LinoSanfilippo@gmx.de>,
	Andy Shevchenko <andy.shevchenko@gmail.com>
Subject: Re: [PATCH v2 1/4] serial: Rename vars in uart_get_rs485_config()
Date: Tue, 30 Aug 2022 12:03:52 +0300 (EEST)	[thread overview]
Message-ID: <4cb3cc81-23b6-2df4-41b-853e34b78fb8@linux.intel.com> (raw)
In-Reply-To: <Yw3QMI0m2X/8aL7z@kroah.com>

[-- Attachment #1: Type: text/plain, Size: 1912 bytes --]

On Tue, 30 Aug 2022, Greg Kroah-Hartman wrote:

> On Tue, Aug 30, 2022 at 10:29:53AM +0300, Ilpo Järvinen wrote:
> > Make variable names to match uart_set_rs485_config() ones:
> > 	- rs485 -> rs485_user
> > 	- aux -> rs485
> > 
> > Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
> > Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
> > ---
> >  drivers/tty/serial/serial_core.c | 8 ++++----
> >  1 file changed, 4 insertions(+), 4 deletions(-)
> > 
> > diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
> > index 12c87cd201a7..8834414a0b2f 100644
> > --- a/drivers/tty/serial/serial_core.c
> > +++ b/drivers/tty/serial/serial_core.c
> > @@ -1408,16 +1408,16 @@ int uart_rs485_config(struct uart_port *port)
> >  EXPORT_SYMBOL_GPL(uart_rs485_config);
> >  
> >  static int uart_get_rs485_config(struct uart_port *port,
> > -			 struct serial_rs485 __user *rs485)
> > +			 struct serial_rs485 __user *rs485_user)
> >  {
> > +	struct serial_rs485 rs485;
> >  	unsigned long flags;
> > -	struct serial_rs485 aux;
> >  
> >  	spin_lock_irqsave(&port->lock, flags);
> > -	aux = port->rs485;
> > +	rs485 = port->rs485;
> >  	spin_unlock_irqrestore(&port->lock, flags);
> 
> I missed this originally, but why does the lock matter here at all?  You
> are just copying all data out of the structure into an on-stack one, why
> the extra step at all?
> 
> As the structure can change instantly after you release the lock, I
> don't see what the lock is protecting.

At least it cannot return inconsistent serial_rs485 because of the lock. 
Probably not an end of the world if the lock wouldn't be taken and a 
concurrent update of port->rs485 would be allowed to mess up a getted 
serial_rs485 as it seems kind of a high-level/userland concurrency issue 
on the tty. Anyway, that seems to be the only reason really.

It's orthogonal to the patch series though.

-- 
 i.

  reply	other threads:[~2022-08-30  9:03 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-30  7:29 [PATCH v2 0/4] serial: Create kserial_rs485 to get rid of padding Ilpo Järvinen
2022-08-30  7:29 ` [PATCH v2 1/4] serial: Rename vars in uart_get_rs485_config() Ilpo Järvinen
2022-08-30  8:54   ` Greg Kroah-Hartman
2022-08-30  9:03     ` Ilpo Järvinen [this message]
2022-08-30  7:29 ` [PATCH v2 2/4] serial: add helpers to copy serial_rs485 from/to userspace Ilpo Järvinen
2022-08-30  7:29 ` [PATCH v2 3/4] serial: Convert serial_rs485 to kernel doc Ilpo Järvinen
2022-08-30  7:29 ` [PATCH v2 4/4] serial: Add kserial_rs485 to avoid wasted space due to .padding Ilpo Järvinen
2022-08-30  7:29   ` Ilpo Järvinen
2022-08-30  8:01   ` Jiri Slaby
2022-08-30  8:01     ` Jiri Slaby
2022-08-30  8:44     ` Ilpo Järvinen
2022-08-30  8:44       ` Ilpo Järvinen
2022-08-30  8:49   ` Greg Kroah-Hartman
2022-08-30  8:49     ` Greg Kroah-Hartman
2022-08-30  9:34     ` Ilpo Järvinen
2022-08-30  9:34       ` Ilpo Järvinen
2022-08-30  8:52   ` Greg Kroah-Hartman
2022-08-30  8:52     ` Greg Kroah-Hartman
2022-08-30  9:26     ` Ilpo Järvinen
2022-08-30  9:26       ` Ilpo Järvinen
2022-08-30  9:33       ` Greg Kroah-Hartman
2022-08-30  9:33         ` Greg Kroah-Hartman
2022-08-30 10:14         ` Ilpo Järvinen
2022-08-30 10:14           ` Ilpo Järvinen

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=4cb3cc81-23b6-2df4-41b-853e34b78fb8@linux.intel.com \
    --to=ilpo.jarvinen@linux.intel.com \
    --cc=LinoSanfilippo@gmx.de \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=andy.shevchenko@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=jirislaby@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-serial@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.