lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Fri, 26 Apr 2019 08:23:12 +0200
From:   Johan Hovold <johan@...nel.org>
To:     "Ji-Ze Hong (Peter Hong)" <hpeter@...il.com>
Cc:     peter_hong@...tek.com.tw, johan@...nel.org,
        gregkh@...uxfoundation.org, linux-usb@...r.kernel.org,
        linux-kernel@...r.kernel.org,
        "Ji-Ze Hong (Peter Hong)" <hpeter+linux_kernel@...il.com>,
        Oliver Neukum <oneukum@...e.com>
Subject: Re: [PATCH V8 1/4] USB: serial: f81232: clear overrun flag

On Fri, Apr 19, 2019 at 10:45:30AM +0800, Ji-Ze Hong (Peter Hong) wrote:
> The F81232 will report data and LSR with bulk like following format:
> bulk-in data: [LSR(1Byte)+DATA(1Byte)][LSR(1Byte)+DATA(1Byte)]...
> 
> LSR will auto clear frame/parity/break error flag when reading by H/W,
> but overrrun will only cleared when reading LSR. So this patch add a
> worker to read LSR when overrun and flush the worker on close() &
> suspend().
> 
> Cc: Oliver Neukum <oneukum@...e.com>
> Signed-off-by: Ji-Ze Hong (Peter Hong) <hpeter+linux_kernel@...il.com>
> ---
> v8:
> 	1: Fix usb_submit_urb() in f81232_resume() with GFP_NOIO, not
> 	   GFP_KERNEL.
> 
> v7:
> 	1: Remove serial->suspending check
> 	2: Add port priv is_port_open to save port open state. We'll
> 	   register interrupt-in urb in f81232_resume() when port is
> 	   opened.
> 	3: Using usb_kill_urb for read/interrupt urb to ensure urb
> 	   stopped.

>  drivers/usb/serial/f81232.c | 97 +++++++++++++++++++++++++++++++++++++++++----
>  1 file changed, 89 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/usb/serial/f81232.c b/drivers/usb/serial/f81232.c
> index 0dcdcb4b2cde..1f0dd4087d79 100644
> --- a/drivers/usb/serial/f81232.c
> +++ b/drivers/usb/serial/f81232.c
> @@ -41,12 +41,15 @@ MODULE_DEVICE_TABLE(usb, id_table);
>  #define FIFO_CONTROL_REGISTER		(0x02 + SERIAL_BASE_ADDRESS)
>  #define LINE_CONTROL_REGISTER		(0x03 + SERIAL_BASE_ADDRESS)
>  #define MODEM_CONTROL_REGISTER		(0x04 + SERIAL_BASE_ADDRESS)
> +#define LINE_STATUS_REGISTER		(0x05 + SERIAL_BASE_ADDRESS)
>  #define MODEM_STATUS_REGISTER		(0x06 + SERIAL_BASE_ADDRESS)
>  
>  struct f81232_private {
>  	struct mutex lock;
>  	u8 modem_control;
>  	u8 modem_status;
> +	bool is_port_open;

This patch can be simplified by using the tty_port_initialized() macro
in resume instead of adding a new open flag. This is the common way USB
serial drivers deal with this and will allow a lot the new locking to go
away.

> +static int f81232_resume(struct usb_serial *serial)
> +{
> +	struct usb_serial_port *port = serial->port[0];
> +	struct f81232_private *port_priv = usb_get_serial_port_data(port);
> +	int result = 0;
> +
> +	mutex_lock(&port_priv->lock);
> +
> +	if (port_priv && port_priv->is_port_open) {
> +		result = usb_submit_urb(port->interrupt_in_urb, GFP_NOIO);
> +		if (result) {
> +			dev_err(&port->dev,
> +					"%s: submit interrupt urb failed: %d",
> +					__func__, result);

Missing '\n', also please drop the function prefix.

Johan

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ