Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S966247AbbBCPWy (ORCPT ); Tue, 3 Feb 2015 10:22:54 -0500 Received: from mail-qa0-f45.google.com ([209.85.216.45]:44174 "EHLO mail-qa0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965892AbbBCPWr (ORCPT ); Tue, 3 Feb 2015 10:22:47 -0500 Message-ID: <54D0E7C4.8070308@hurleysoftware.com> Date: Tue, 03 Feb 2015 10:22:44 -0500 From: Peter Hurley User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.4.0 MIME-Version: 1.0 To: Michal Simek CC: linux-kernel@vger.kernel.org, monstr@monstr.eu, Sebastian Andrzej Siewior , Jiri Slaby , Alan Cox , Yoshihiro YUNOMAE , Andy Shevchenko , Ricardo Ribalda Delgado , Tony Lindgren , linux-serial@vger.kernel.org, Greg Kroah-Hartman , Ingo Molnar Subject: Re: [PATCH v2 2/2] tty: serial: 8250_core: Check that port->line is >=0 References: <7904178c3dfbf08191514c8436e66d711455a17c.1422957699.git.michal.simek@xilinx.com> In-Reply-To: <7904178c3dfbf08191514c8436e66d711455a17c.1422957699.git.michal.simek@xilinx.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2229 Lines: 67 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 > --- > > 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]; > /* > -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/