[PATCH] TTY: serial, document ignoring of uart->ops->startup error

From: Jiri Slaby
Date: Wed Aug 17 2011 - 07:48:31 EST


When a user has SYS_ADMIN capabilities and uart->ops->startup returns
an error in uart_startup, we silently drop the error. We then return 0
and behave as if it didn't fail. (Not quite, since we set TTY_IO_ERROR
bit and leave ASYNC_INITIALIZED bit cleared.)

This all is to allow setserial to work with improperly configured or
unconfigured ports. User can thus set port properties and reconfigure
properly.

This patch only documents this behavior.

Signed-off-by: Jiri Slaby <jslaby@xxxxxxx>
Cc: Alan Cox <alan@xxxxxxxxxxxxxxxxxxx>
Cc: Greg KH <gregkh@xxxxxxx>
Cc: Russel King <linux@xxxxxxxxxxxxxxxx>
---
On 08/17/2011 12:13 PM, Alan Cox wrote:
> On Wed, 17 Aug 2011 11:25:27 +0200
> Jiri Slaby <jirislaby@xxxxxxxxx> wrote:
>
>> Hi,
>>
>> while I was in the process of uart cleanup, I found this:
>> static int uart_startup(...) {
>> ...
>> retval = port->ops->startup(port);
>> ...
>> if (retval && capable(CAP_SYS_ADMIN))
>> retval = 0;
>>
>> return retval;
>> }
>>
>> Why CAP_SYS_ADMIN should not see the failing port startup? Does anybody
>> from you remember if it is for some kind of possibility to later
>> re-autoconfigure the port or something like that?
>
> In a word - setserial

Yes, thanks. So I assume especially for the configuration of port/irq/type. So
this is why this is special to tty/serial and USB serials don't need to support
this.

drivers/tty/serial/serial_core.c | 5 +++++
1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
index db7912c..a3efbea 100644
--- a/drivers/tty/serial/serial_core.c
+++ b/drivers/tty/serial/serial_core.c
@@ -200,6 +200,11 @@ static int uart_startup(struct tty_struct *tty, struct uart_state *state, int in
clear_bit(TTY_IO_ERROR, &tty->flags);
}

+ /*
+ * This is to allow setserial on this port. People may want to set
+ * port/irq/type and then reconfigure the port properly if it failed
+ * now.
+ */
if (retval && capable(CAP_SYS_ADMIN))
retval = 0;

--
1.7.6


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/