linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Helge Deller <deller@gmx.de>
To: Jiri Slaby <jslaby@suse.cz>, gregkh@linuxfoundation.org
Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org,
	Geert Uytterhoeven <geert@linux-m68k.org>,
	"James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>,
	Chris Zankel <chris@zankel.net>,
	Max Filippov <jcmvbkbc@gmail.com>,
	Laurentiu Tudor <laurentiu.tudor@nxp.com>,
	Felipe Balbi <balbi@kernel.org>
Subject: Re: [PATCH 3/8] tty: don't store semi-state into tty drivers
Date: Fri, 23 Jul 2021 18:37:06 +0200	[thread overview]
Message-ID: <584aafd9-843c-6f26-ae0c-3cddaff3000c@gmx.de> (raw)
In-Reply-To: <20210723074317.32690-4-jslaby@suse.cz>

On 7/23/21 9:43 AM, Jiri Slaby wrote:
> When a tty driver pointer is used as a return value of struct
> console's device() hook, don't store a semi-state into global variable
> which holds the tty driver. It could mean console::device() would return
> a bogus value. This is important esp. after the next patch where we
> switch from alloc_tty_driver to tty_alloc_driver. tty_alloc_driver
> returns ERR_PTR in case of error and that might have unexpected results
> as the code doesn't expect this.
>
> Signed-off-by: Jiri Slaby <jslaby@suse.cz>
> Cc: Geert Uytterhoeven <geert@linux-m68k.org>
> Cc: "James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>
> Cc: Helge Deller <deller@gmx.de>
> Cc: Chris Zankel <chris@zankel.net>
> Cc: Max Filippov <jcmvbkbc@gmail.com>
> Cc: Laurentiu Tudor <laurentiu.tudor@nxp.com>
> Cc: Felipe Balbi <balbi@kernel.org>
> ---
>   arch/m68k/emu/nfcon.c                  | 27 +++++++++++---------
>   arch/parisc/kernel/pdc_cons.c          | 28 +++++++++++----------
>   arch/xtensa/platforms/iss/console.c    | 33 +++++++++++++-----------
>   drivers/tty/amiserial.c                | 35 ++++++++++++++------------
>   drivers/tty/ehv_bytechan.c             | 28 ++++++++++++---------
>   drivers/tty/hvc/hvsi.c                 | 35 ++++++++++++++------------
>   drivers/usb/gadget/function/u_serial.c | 32 ++++++++++++-----------
>   7 files changed, 119 insertions(+), 99 deletions(-)
>
...

You may add:

Acked-by: Helge Deller <deller@gmx.de>	# parisc

to the whole series (specifically patches 3, 4 and 8) regarding the parisc changes.

Thank you!
Helge

>
> diff --git a/arch/parisc/kernel/pdc_cons.c b/arch/parisc/kernel/pdc_cons.c
> index 39ccad063533..650cb01203de 100644
> --- a/arch/parisc/kernel/pdc_cons.c
> +++ b/arch/parisc/kernel/pdc_cons.c
> @@ -138,6 +138,7 @@ static struct tty_driver *pdc_console_tty_driver;
>
>   static int __init pdc_console_tty_driver_init(void)
>   {
> +	struct tty_driver *driver;
>   	int err;
>
>   	/* Check if the console driver is still registered.
> @@ -160,31 +161,32 @@ static int __init pdc_console_tty_driver_init(void)
>   	printk(KERN_INFO "The PDC console driver is still registered, removing CON_BOOT flag\n");
>   	pdc_cons.flags &= ~CON_BOOT;
>
> -	pdc_console_tty_driver = alloc_tty_driver(1);
> -
> -	if (!pdc_console_tty_driver)
> +	driver = alloc_tty_driver(1);
> +	if (!driver)
>   		return -ENOMEM;
>
>   	tty_port_init(&tty_port);
>
> -	pdc_console_tty_driver->driver_name = "pdc_cons";
> -	pdc_console_tty_driver->name = "ttyB";
> -	pdc_console_tty_driver->major = MUX_MAJOR;
> -	pdc_console_tty_driver->minor_start = 0;
> -	pdc_console_tty_driver->type = TTY_DRIVER_TYPE_SYSTEM;
> -	pdc_console_tty_driver->init_termios = tty_std_termios;
> -	pdc_console_tty_driver->flags = TTY_DRIVER_REAL_RAW |
> +	driver->driver_name = "pdc_cons";
> +	driver->name = "ttyB";
> +	driver->major = MUX_MAJOR;
> +	driver->minor_start = 0;
> +	driver->type = TTY_DRIVER_TYPE_SYSTEM;
> +	driver->init_termios = tty_std_termios;
> +	driver->flags = TTY_DRIVER_REAL_RAW |
>   		TTY_DRIVER_RESET_TERMIOS;
> -	tty_set_operations(pdc_console_tty_driver, &pdc_console_tty_ops);
> -	tty_port_link_device(&tty_port, pdc_console_tty_driver, 0);
> +	tty_set_operations(driver, &pdc_console_tty_ops);
> +	tty_port_link_device(&tty_port, driver, 0);
>
> -	err = tty_register_driver(pdc_console_tty_driver);
> +	err = tty_register_driver(driver);
>   	if (err) {
>   		printk(KERN_ERR "Unable to register the PDC console TTY driver\n");
>   		tty_port_destroy(&tty_port);
>   		return err;
>   	}
>
> +	pdc_console_tty_driver = driver;
> +
>   	return 0;
>   }
>   device_initcall(pdc_console_tty_driver_init);
...

  parent reply	other threads:[~2021-07-23 16:37 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-23  7:43 [PATCH 0/8] Get rid of old tty_driver functions Jiri Slaby
2021-07-23  7:43 ` [PATCH 1/8] xtensa: ISS: don't panic in rs_init Jiri Slaby
2021-07-23 10:18   ` Max Filippov
2021-07-23  7:43 ` [PATCH 2/8] hvsi: don't panic on tty_register_driver failure Jiri Slaby
2021-07-23  7:43 ` [PATCH 3/8] tty: don't store semi-state into tty drivers Jiri Slaby
2021-07-23 10:23   ` Max Filippov
2021-07-23 16:37   ` Helge Deller [this message]
2021-07-23  7:43 ` [PATCH 4/8] tty: stop using alloc_tty_driver Jiri Slaby
2021-07-23  7:49   ` Samuel Iglesias Gonsálvez
2021-07-23  7:57   ` Christian Borntraeger
2021-07-23 10:16   ` David Sterba
2021-07-23 10:30   ` Max Filippov
2021-07-23  7:43 ` [PATCH 5/8] tty: drop alloc_tty_driver Jiri Slaby
2021-07-23  7:43 ` [PATCH 6/8] tty: make tty_set_operations an inline Jiri Slaby
2021-07-23  7:43 ` [PATCH 7/8] tty: drop put_tty_driver Jiri Slaby
2021-07-23  7:49   ` Samuel Iglesias Gonsálvez
2021-07-23  7:55   ` Christian Borntraeger
2021-07-23 10:16   ` David Sterba
2021-07-23 10:32   ` Max Filippov
2021-07-23 12:50   ` Alex Elder
2021-07-23  7:43 ` [PATCH 8/8] tty: pdc_cons, free tty_driver upon failure Jiri Slaby
2021-07-27 10:18 ` [PATCH 0/8] Get rid of old tty_driver functions 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=584aafd9-843c-6f26-ae0c-3cddaff3000c@gmx.de \
    --to=deller@gmx.de \
    --cc=James.Bottomley@HansenPartnership.com \
    --cc=balbi@kernel.org \
    --cc=chris@zankel.net \
    --cc=geert@linux-m68k.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=jcmvbkbc@gmail.com \
    --cc=jslaby@suse.cz \
    --cc=laurentiu.tudor@nxp.com \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).