lkml.org 
[lkml]   [2002]   [Aug]   [26]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
Subject[BUG/PATCH] : bug in tty_default_put_char()
From
	Hi,

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
is.

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.

Regards,

Jean

-----------------------------------------------
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",
+ kdevname(tty->device));
}

/*
-
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/
\
 
 \ /
  Last update: 2005-03-22 13:28    [W:0.095 / U:0.828 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site