All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] tty/metag_da: initialize number_written to zero
@ 2016-01-26 23:37 ` Colin King
  0 siblings, 0 replies; 8+ messages in thread
From: Colin King @ 2016-01-26 23:37 UTC (permalink / raw)
  To: James Hogan, Greg Kroah-Hartman, Jiri Slaby,
	linux-metag-u79uwXL29TY76Z2rM5mHXA
  Cc: linux-kernel-u79uwXL29TY76Z2rM5mHXA

From: Colin Ian King <colin.king-Z7WLFzj8eWMS+FvcfC7Uqw@public.gmane.org>

number_written is not initialized, so it can be any value. In the
case where dport->xmit_cnt is zero, number_written is not set
and subsequent accesses to it will be reading a garbage value.
Fix this by initializing it to zero for the case when
dport->xmit_count is zero.

Signed-off-by: Colin Ian King <colin.king-Z7WLFzj8eWMS+FvcfC7Uqw@public.gmane.org>
---
 drivers/tty/metag_da.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/tty/metag_da.c b/drivers/tty/metag_da.c
index 9325262..3da89c1 100644
--- a/drivers/tty/metag_da.c
+++ b/drivers/tty/metag_da.c
@@ -230,7 +230,7 @@ static int put_channel_data(unsigned int chan)
 {
 	struct dashtty_port *dport;
 	struct tty_struct *tty;
-	int number_written;
+	int number_written = 0;
 	unsigned int count = 0;
 
 	dport = &dashtty_ports[chan];
-- 
2.7.0.rc3

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

end of thread, other threads:[~2016-02-07  7:59 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-01-26 23:37 [PATCH] tty/metag_da: initialize number_written to zero Colin King
2016-01-26 23:37 ` Colin King
     [not found] ` <1453851445-4645-1-git-send-email-colin.king-Z7WLFzj8eWMS+FvcfC7Uqw@public.gmane.org>
2016-01-27 11:42   ` James Hogan
2016-01-27 11:42     ` James Hogan
2016-01-28 18:48     ` Colin Ian King
2016-02-07  7:41       ` Greg Kroah-Hartman
     [not found]         ` <20160207074109.GA6508-U8xfFu+wG4EAvxtiuMwx3w@public.gmane.org>
2016-02-07  7:59           ` Colin Ian King
2016-02-07  7:59             ` Colin Ian King

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.