linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jean Tourrilhes <jt@bougret.hpl.hp.com>
To: Linux kernel mailing list <linux-kernel@vger.kernel.org>,
	Alan Cox <alan@lxorguk.ukuu.org.uk>,
	tytso@mit.edu, Russell King <rmk@arm.linux.org.uk>,
	Andrew Morton <andrewm@uow.edu.eu>
Cc: irda-users@lists.sourceforge.net
Subject: [BUG/PATCH] : bug in tty_default_put_char()
Date: Mon, 26 Aug 2002 11:07:49 -0700	[thread overview]
Message-ID: <20020826180749.GA8630@bougret.hpl.hp.com> (raw)

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

             reply	other threads:[~2002-08-26 18:06 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-08-26 18:07 Jean Tourrilhes [this message]
     [not found] ` <1030388224.2797.2.camel@irongate.swansea.linux.org.uk>
2002-08-26 18:59   ` [BUG/PATCH] : bug in tty_default_put_char() 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20020826180749.GA8630@bougret.hpl.hp.com \
    --to=jt@bougret.hpl.hp.com \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=andrewm@uow.edu.eu \
    --cc=irda-users@lists.sourceforge.net \
    --cc=jt@hpl.hp.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rmk@arm.linux.org.uk \
    --cc=tytso@mit.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).