All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 1/2] tty: serial: 8250_core: Remove trailing whitespaces
@ 2015-02-03 10:01 Michal Simek
  2015-02-03 10:01 ` [PATCH v2 2/2] tty: serial: 8250_core: Check that port->line is >=0 Michal Simek
  0 siblings, 1 reply; 3+ messages in thread
From: Michal Simek @ 2015-02-03 10:01 UTC (permalink / raw)
  To: linux-kernel, monstr
  Cc: Sebastian Andrzej Siewior, Jiri Slaby, Peter Hurley, Alan Cox,
	Yoshihiro YUNOMAE, Andy Shevchenko, Ricardo Ribalda Delgado,
	Tony Lindgren, linux-serial, Greg Kroah-Hartman, Ingo Molnar

No functional changes.

Signed-off-by: Michal Simek <michal.simek@xilinx.com>
---

Changes in v2:
- Do not sign patch

 drivers/tty/serial/8250/8250_core.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/tty/serial/8250/8250_core.c b/drivers/tty/serial/8250/8250_core.c
index 11c66856ba2f..65e52c9109e2 100644
--- a/drivers/tty/serial/8250/8250_core.c
+++ b/drivers/tty/serial/8250/8250_core.c
@@ -884,7 +884,7 @@ static int broken_efr(struct uart_8250_port *up)
 	/*
 	 * Exar ST16C2550 "A2" devices incorrectly detect as
 	 * having an EFR, and report an ID of 0x0201.  See
-	 * http://linux.derkeiler.com/Mailing-Lists/Kernel/2004-11/4812.html 
+	 * http://linux.derkeiler.com/Mailing-Lists/Kernel/2004-11/4812.html
 	 */
 	if (autoconfig_read_divisor_id(up) == 0x0201 && size_fifo(up) == 16)
 		return 1;
@@ -1239,7 +1239,7 @@ static void autoconfig(struct uart_8250_port *up, unsigned int probeflags)
 	serial_out(up, UART_LCR, save_lcr);
 
 	port->fifosize = uart_config[up->port.type].fifo_size;
-	old_capabilities = up->capabilities; 
+	old_capabilities = up->capabilities;
 	up->capabilities = uart_config[port->type].flags;
 	up->tx_loadsz = uart_config[port->type].tx_loadsz;
 
-- 
1.8.2.3

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH v2 2/2] tty: serial: 8250_core: Check that port->line is >=0
  2015-02-03 10:01 [PATCH v2 1/2] tty: serial: 8250_core: Remove trailing whitespaces Michal Simek
@ 2015-02-03 10:01 ` Michal Simek
  2015-02-03 15:22   ` Peter Hurley
  0 siblings, 1 reply; 3+ messages in thread
From: Michal Simek @ 2015-02-03 10:01 UTC (permalink / raw)
  To: linux-kernel, monstr
  Cc: Sebastian Andrzej Siewior, Jiri Slaby, Peter Hurley, Alan Cox,
	Yoshihiro YUNOMAE, Andy Shevchenko, Ricardo Ribalda Delgado,
	Tony Lindgren, linux-serial, Greg Kroah-Hartman, Ingo Molnar

Add one more checking condition which was originally added by:
"tty: serial: 8250_core: use the ->line argument as a hint in
serial8250_find_match_or_unused()"
(sha1: 59b3e898ddfc81a65975043b5eb44103cc29ff6e)

port->line can be setup by DT driver to -1 which needs to
be also checked.

Signed-off-by: Michal Simek <michal.simek@xilinx.com>
---

Changes in v2:
- Change commit message description
- Do not sign patches - Greg reported problem with it

I have similar patch to 59b3e898ddfc81a65975043b5eb44103cc29ff6e
in xilinx tree for a while and port->line can be -1.

The second part of this also should be (what other drivers do)
reading aliases via of_alias_get_id() in of_serial.c:of_platform_serial_probe()
which setup port.line.
---
 drivers/tty/serial/8250/8250_core.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/tty/serial/8250/8250_core.c b/drivers/tty/serial/8250/8250_core.c
index 65e52c9109e2..aab765177763 100644
--- a/drivers/tty/serial/8250/8250_core.c
+++ b/drivers/tty/serial/8250/8250_core.c
@@ -3512,7 +3512,8 @@ static struct uart_8250_port *serial8250_find_match_or_unused(struct uart_port *
 
 	/* try line number first if still available */
 	i = port->line;
-	if (i < nr_uarts && serial8250_ports[i].port.type == PORT_UNKNOWN &&
+	if (i >= 0 && i < nr_uarts &&
+	    serial8250_ports[i].port.type == PORT_UNKNOWN &&
 			serial8250_ports[i].port.iobase == 0)
 		return &serial8250_ports[i];
 	/*
-- 
1.8.2.3

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v2 2/2] tty: serial: 8250_core: Check that port->line is >=0
  2015-02-03 10:01 ` [PATCH v2 2/2] tty: serial: 8250_core: Check that port->line is >=0 Michal Simek
@ 2015-02-03 15:22   ` Peter Hurley
  0 siblings, 0 replies; 3+ messages in thread
From: Peter Hurley @ 2015-02-03 15:22 UTC (permalink / raw)
  To: Michal Simek
  Cc: linux-kernel, monstr, Sebastian Andrzej Siewior, Jiri Slaby,
	Alan Cox, Yoshihiro YUNOMAE, Andy Shevchenko,
	Ricardo Ribalda Delgado, Tony Lindgren, linux-serial,
	Greg Kroah-Hartman, Ingo Molnar

Hi Michal,

On 02/03/2015 05:01 AM, Michal Simek wrote:
> Add one more checking condition which was originally added by:
> "tty: serial: 8250_core: use the ->line argument as a hint in
> serial8250_find_match_or_unused()"
> (sha1: 59b3e898ddfc81a65975043b5eb44103cc29ff6e)
> 
> port->line can be setup by DT driver to -1 which needs to
> be also checked.

What driver is initializing port->line to -1?

Drivers using of_alias_get_id() and/or the platform device id
need to clamp port->line to a valid index before port
registration (or in the case of 8250-type drivers before
8250 port registration.


> Signed-off-by: Michal Simek <michal.simek@xilinx.com>
> ---
> 
> Changes in v2:
> - Change commit message description
> - Do not sign patches - Greg reported problem with it
> 
> I have similar patch to 59b3e898ddfc81a65975043b5eb44103cc29ff6e
> in xilinx tree for a while and port->line can be -1.
> 
> The second part of this also should be (what other drivers do)

What 'second part of this'?

I only see one change here (and I'd rather see the 8250 core
return NULL if port->line < 0).

Regards,
Peter Hurley


> reading aliases via of_alias_get_id() in of_serial.c:of_platform_serial_probe()
> which setup port.line.
> ---
>  drivers/tty/serial/8250/8250_core.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/tty/serial/8250/8250_core.c b/drivers/tty/serial/8250/8250_core.c
> index 65e52c9109e2..aab765177763 100644
> --- a/drivers/tty/serial/8250/8250_core.c
> +++ b/drivers/tty/serial/8250/8250_core.c
> @@ -3512,7 +3512,8 @@ static struct uart_8250_port *serial8250_find_match_or_unused(struct uart_port *
>  
>  	/* try line number first if still available */
>  	i = port->line;
> -	if (i < nr_uarts && serial8250_ports[i].port.type == PORT_UNKNOWN &&
> +	if (i >= 0 && i < nr_uarts &&
> +	    serial8250_ports[i].port.type == PORT_UNKNOWN &&
>  			serial8250_ports[i].port.iobase == 0)
>  		return &serial8250_ports[i];
>  	/*
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-02-03 15:22 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-02-03 10:01 [PATCH v2 1/2] tty: serial: 8250_core: Remove trailing whitespaces Michal Simek
2015-02-03 10:01 ` [PATCH v2 2/2] tty: serial: 8250_core: Check that port->line is >=0 Michal Simek
2015-02-03 15:22   ` Peter Hurley

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.