mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Vegard Nossum <vegard.nossum@gmail.com>
To: Alan Cox <alan@lxorguk.ukuu.org.uk>
Cc: Pekka Enberg <penberg@cs.helsinki.fi>, linux-kernel@vger.kernel.org
Subject: [PATCH] tty_ldisc: propagate errors from tty_ldisc_release
Date: Mon, 15 Jun 2009 17:39:26 +0200	[thread overview]
Message-ID: <20090615153925.GA27696@damson.getinternet.no> (raw)

>From ea6ee429b1f173e6905c3e6251649a6caf93d533 Mon Sep 17 00:00:00 2001
From: Vegard Nossum <vegard.nossum@gmail.com>
Date: Mon, 15 Jun 2009 17:26:35 +0200
Subject: [PATCH] tty_ldisc: propagate errors from tty_ldisc_release

This is probably better than just ignoring the errors.

Signed-off-by: Vegard Nossum <vegard.nossum@gmail.com>
---
 drivers/char/tty_ldisc.c |   26 ++++++++++++++++++++------
 include/linux/tty.h      |    2 +-
 2 files changed, 21 insertions(+), 7 deletions(-)

diff --git a/drivers/char/tty_ldisc.c b/drivers/char/tty_ldisc.c
index 39c8f86..1d39e2b 100644
--- a/drivers/char/tty_ldisc.c
+++ b/drivers/char/tty_ldisc.c
@@ -840,17 +840,24 @@ int tty_ldisc_setup(struct tty_struct *tty, struct tty_struct *o_tty)
  *	Called during the final close of a tty/pty pair in order to shut down
  *	the line discpline layer. On exit the ldisc assigned is N_TTY and the
  *	ldisc has not been opened.
+ *
+ *	Returns 0 on success, negative error code otherwise.
  */
 
-void tty_ldisc_release(struct tty_struct *tty, struct tty_struct *o_tty)
+int tty_ldisc_release(struct tty_struct *tty, struct tty_struct *o_tty)
 {
+	int err;
+
 	/*
 	 * Prevent flush_to_ldisc() from rescheduling the work for later.  Then
 	 * kill any delayed work. As this is the final close it does not
 	 * race with the set_ldisc code path.
 	 */
 
-	tty_ldisc_halt(tty);
+	err = tty_ldisc_halt(tty);
+	if (err < 0)
+		return err;
+
 	flush_scheduled_work();
 
 	/*
@@ -859,7 +866,16 @@ void tty_ldisc_release(struct tty_struct *tty, struct tty_struct *o_tty)
 	 * side is zero.
 	 */
 
-	tty_ldisc_wait_idle(tty);
+	err = tty_ldisc_wait_idle(tty);
+	if (err < 0)
+		return err;
+
+	/* This will need doing differently if we need to lock */
+	if (o_tty) {
+		err = tty_ldisc_release(o_tty, NULL);
+		if (err < 0)
+			return err;
+	}
 
 	/*
 	 * Shutdown the current line discipline, and reset it to N_TTY.
@@ -868,9 +884,7 @@ void tty_ldisc_release(struct tty_struct *tty, struct tty_struct *o_tty)
 	 */
 
 	tty_ldisc_reinit(tty);
-	/* This will need doing differently if we need to lock */
-	if (o_tty)
-		tty_ldisc_release(o_tty, NULL);
+	return 0;
 }
 
 /**
diff --git a/include/linux/tty.h b/include/linux/tty.h
index 1488d8c..474abd6 100644
--- a/include/linux/tty.h
+++ b/include/linux/tty.h
@@ -461,7 +461,7 @@ extern int tty_register_ldisc(int disc, struct tty_ldisc_ops *new_ldisc);
 extern int tty_unregister_ldisc(int disc);
 extern int tty_set_ldisc(struct tty_struct *tty, int ldisc);
 extern int tty_ldisc_setup(struct tty_struct *tty, struct tty_struct *o_tty);
-extern void tty_ldisc_release(struct tty_struct *tty, struct tty_struct *o_tty);
+extern int tty_ldisc_release(struct tty_struct *tty, struct tty_struct *o_tty);
 extern void tty_ldisc_init(struct tty_struct *tty);
 extern void tty_ldisc_begin(void);
 /* This last one is just for the tty layer internals and shouldn't be used elsewhere */
-- 
1.6.0.6


             reply	other threads:[~2009-06-15 15:39 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-06-15 15:39 Vegard Nossum [this message]
2009-06-15 15:51 ` Alan Cox

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=20090615153925.GA27696@damson.getinternet.no \
    --to=vegard.nossum@gmail.com \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=linux-kernel@vger.kernel.org \
    --cc=penberg@cs.helsinki.fi \
    /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

all inboxes | Powered by JetHome®