lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1360161902-25329-3-git-send-email-james.hogan@imgtec.com>
Date:	Wed, 6 Feb 2013 14:45:02 +0000
From:	James Hogan <james.hogan@...tec.com>
To:	Greg Kroah-Hartman <gregkh@...uxfoundation.org>
CC:	Jiri Slaby <jslaby@...e.cz>, <linux-kernel@...r.kernel.org>,
	James Hogan <james.hogan@...tec.com>
Subject: [PATCH 2/2] tty: metag_da: avoid getting tty kref in dashtty_timer()

Getting the tty kref in dashtty_timer() is no longer necessary since it
isn't needed in fetch_data() any longer (due to changes which make the
tty flip functions refer to tty_ports instead of tty_structs), so just
pass around a channel number instead.

Signed-off-by: James Hogan <james.hogan@...tec.com>
Cc: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
Acked-by: Jiri Slaby <jslaby@...e.cz>
---
 drivers/tty/metag_da.c |   31 ++++++++++++++-----------------
 1 files changed, 14 insertions(+), 17 deletions(-)

diff --git a/drivers/tty/metag_da.c b/drivers/tty/metag_da.c
index fc2a36b..0e88862 100644
--- a/drivers/tty/metag_da.c
+++ b/drivers/tty/metag_da.c
@@ -147,9 +147,8 @@ static int chancall(int in_bios_function, int in_channel,
 /*
  * Attempts to fetch count bytes from channel and returns actual count.
  */
-static int fetch_data(struct tty_struct *tty)
+static int fetch_data(unsigned int channel)
 {
-	unsigned int channel = tty->index;
 	struct dashtty_port *dport = &dashtty_ports[channel];
 	int received = 0;
 
@@ -180,31 +179,31 @@ unlock:
 }
 
 /**
- * find_channel_to_poll() - Returns kref to the next channel tty to poll.
- * Returns:	The TTY of the next channel to poll, or NULL if no TTY needs
- *		polling. Release with tty_kref_put().
+ * find_channel_to_poll() - Returns number of the next channel to poll.
+ * Returns:	The number of the next channel to poll, or -1 if none need
+ *		polling.
  */
-static struct tty_struct *find_channel_to_poll(void)
+static int find_channel_to_poll(void)
 {
 	static int last_polled_channel;
 	int last = last_polled_channel;
 	int chan;
-	struct tty_struct *tty = NULL;
+	struct dashtty_port *dport;
 
 	for (chan = last + 1; ; ++chan) {
 		if (chan >= NUM_TTY_CHANNELS)
 			chan = 0;
 
-		tty = tty_port_tty_get(&dashtty_ports[chan].port);
-		if (tty) {
+		dport = &dashtty_ports[chan];
+		if (dport->rx_buf) {
 			last_polled_channel = chan;
-			return tty;
+			return chan;
 		}
 
 		if (chan == last)
 			break;
 	}
-	return tty;
+	return -1;
 }
 
 /**
@@ -302,19 +301,17 @@ static int put_data(void *arg)
  */
 static void dashtty_timer(unsigned long ignored)
 {
-	struct tty_struct *tty;
+	int channel;
 
 	/* If there are no ports open do nothing and don't poll again. */
 	if (!atomic_read(&num_channels_need_poll))
 		return;
 
-	tty = find_channel_to_poll();
+	channel = find_channel_to_poll();
 
 	/* Did we find a channel to poll? */
-	if (tty) {
-		fetch_data(tty);
-		tty_kref_put(tty);
-	}
+	if (channel >= 0)
+		fetch_data(channel);
 
 	mod_timer_pinned(&poll_timer, jiffies + DA_TTY_POLL);
 }
-- 
1.7.7.6


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ