From: Jean Tourrilhes <jt@bo...> - 2002-08-26 18:09:34
Bug : tty_default_put_char() doesn't check the return value of
tty->driver.write(). However, the later may fail if buffers are full.
Solution : It's not obvious what should be done. The attached
patch is certainly wrong, but gives you an idea of what the problem
Long story :
User weant to do PPP over IrCOMM. "chat" opens ircomm device
in non blocking mode and write char by char. I suspect that it's using
the above call, but can't verify (because it doesn't happen to me). As
IrCOMM has not finished its initialisation (the open was
non-blocking), it refuses the write and returns 0.
Character dropped, user unhappy, bugs me about it.
I'll try to workaround that in IrCOMM.
diff -u -p linux/drivers/char/tty_io.t1.c linux/drivers/char/tty_io.c
--- linux/drivers/char/tty_io.t1.c Mon Aug 26 10:55:33 2002
+++ linux/drivers/char/tty_io.c Mon Aug 26 10:58:34 2002
@@ -2021,7 +2021,11 @@ static void initialize_tty_struct(struct
void tty_default_put_char(struct tty_struct *tty, unsigned char ch)
- tty->driver.write(tty, 0, &ch, 1);
+ int ret = tty->driver.write(tty, 0, &ch, 1);
+ /* This might fail if the lower layer is already full - Jean II */
+ if (ret == 0)
+ printk(KERN_WARNING "Warning: dev (%s) put_char failed\n",
From: Russell King <rmk@ar...> - 2002-08-26 19:31:47
On Mon, Aug 26, 2002 at 11:07:49AM -0700, Jean Tourrilhes wrote:
> Bug : tty_default_put_char() doesn't check the return value of
> tty->driver.write(). However, the later may fail if buffers are full.
> Solution : It's not obvious what should be done. The attached
> patch is certainly wrong, but gives you an idea of what the problem
Every invocation of the put_char() method should be preceded by a check
to ensure that there is sufficient space in the drivers buffer (via the
drivers write_room() call.) Could you add a BUG() on this condition
and get some call traces please?
> I'll try to workaround that in IrCOMM.
I don't think that should be necessary. The tty layer is obviously
doing something it shouldn't (trying to stuff characters into a buffer
of zero size) so it should get fixed.
Russell King (rmk@...) The developer of ARM Linux