nozomi: ERESTARTSYS to userspace? - Kernel

This is a discussion on nozomi: ERESTARTSYS to userspace? - Kernel ; Hi, static int ntty_write(struct tty_struct *tty, const unsigned char *buffer, int count) { int rval = -EINVAL; struct nozomi *dc = get_dc_by_tty(tty); struct port *port = (struct port *)tty->driver_data; unsigned long flags; /* DBG1( "WRITEx: %d, index = %d", count, ...

+ Reply to Thread
Results 1 to 2 of 2

Thread: nozomi: ERESTARTSYS to userspace?

  1. nozomi: ERESTARTSYS to userspace?

    Hi,

    static int ntty_write(struct tty_struct *tty, const unsigned char *buffer,
    int count)
    {
    int rval = -EINVAL;
    struct nozomi *dc = get_dc_by_tty(tty);
    struct port *port = (struct port *)tty->driver_data;
    unsigned long flags;

    /* DBG1( "WRITEx: %d, index = %d", count, index); */

    if (!dc || !port)
    return -ENODEV;

    if (unlikely(down_trylock(&port->tty_sem))) {
    /*
    * must test lock as tty layer wraps calls
    * to this function with BKL
    */
    dev_err(&dc->pdev->dev, "Would have deadlocked - "
    "return ERESTARTSYS\n");
    return -ERESTARTSYS;
    }

    The use of ERESTARTSYS seems bogus to me, no signal is pending and this flag
    would reach userspace (that is not permitted), am I right?

    --js
    -
    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/

  2. Re: nozomi: ERESTARTSYS to userspace?

    > if (unlikely(down_trylock(&port->tty_sem))) {
    > /*
    > * must test lock as tty layer wraps calls
    > * to this function with BKL
    > */
    > dev_err(&dc->pdev->dev, "Would have deadlocked - "
    > "return ERESTARTSYS\n");
    > return -ERESTARTSYS;
    > }
    >
    > The use of ERESTARTSYS seems bogus to me, no signal is pending and this flag
    > would reach userspace (that is not permitted), am I right?


    serial driver write methods are called from the ldisc not the tty so the
    code is in fact totally bogus.

    I suspect what is needed (other than to take the entire driver to bits
    and put it back together using serial_core) is

    if (down_trylock(&port->tty_sem))
    return 0;

    and the driver is then required to wake the write wait queue when that
    condition becomes false - or at least before/when it runs out of
    data (which currently it doesn't seem to for all cases).

    Lots of other breakage in it as well (termios function is totally bogus,
    tty_flip_queue_function is a no-op) etc etc

    Alan
    -
    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/

+ Reply to Thread