public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [BUG/PATCH] : bug in tty_default_put_char()
@ 2002-08-26 18:07 Jean Tourrilhes
       [not found] ` <1030388224.2797.2.camel@irongate.swansea.linux.org.uk>
  2002-08-26 19:31 ` Russell King
  0 siblings, 2 replies; 7+ messages in thread
From: Jean Tourrilhes @ 2002-08-26 18:07 UTC (permalink / raw)
  To: Linux kernel mailing list, Alan Cox, tytso, Russell King,
	Andrew Morton
  Cc: irda-users

	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));
 }
 
 /*

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2002-08-28 23:12 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-08-26 18:07 [BUG/PATCH] : bug in tty_default_put_char() Jean Tourrilhes
     [not found] ` <1030388224.2797.2.camel@irongate.swansea.linux.org.uk>
2002-08-26 18:59   ` Jean Tourrilhes
2002-08-26 19:07     ` Alan Cox
2002-08-26 20:17       ` Russell King
2002-08-26 19:31 ` Russell King
     [not found]   ` <20020826195346.GC8749@bougret.hpl.hp.com>
     [not found]     ` <20020826210159.E4763@flint.arm.linux.org.uk>
     [not found]       ` <20020826201732.GE8749@bougret.hpl.hp.com>
     [not found]         ` <20020826212223.H4763@flint.arm.linux.org.uk>
2002-08-28 22:41           ` Jean Tourrilhes
2002-08-28 23:16             ` Russell King

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox